---
title: "Comment by Isaac Way on \"Using React Context API with NextJS\" | Hashnode"
description: "This is well written but it feels like it&#39;s half of a tutorial. The above implementation is completely unusable because the value of the context is going to"
url: "https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3/comment/6005a6ab7b30c23b714ab5ff"
---

[Discussion](https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3)

Comment [Using React Context API with NextJS](https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3)

[Isaac Way](https://hashnode.com/@idoubleu)

[Jan 18, 2021](https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3/comment/6005a6ab7b30c23b714ab5ff)

This is well written but it feels like it's half of a tutorial. The above implementation is completely unusable because the value of the context is going to be reset any time the user. I'm sorry but I'm just so frustrated. Every. Single. Tutorial about Contexts and NextJS is like this. I keep searching and searching for an example of actually using these things but all I get is articles like this one, where you're just using the context as a place to store data for a single page.

Contexts are useful because they allow components and pages to share state, right? Well then, what is the point of using one if your state is just going to be reset whenever you redirect? What is the point of having login data that disappears when you change pages? Am I missing something here? I do not understand how the above example is useful in any way if the context is just reset to the default value every time you redirect to a new page.

Edit: Yeah I was missing something. Sorry lol. I just needed to use <Link> to redirect instead of vanilla <a> tag. Maybe include that in the article for future dummies?

[Alan Montgomery](https://hashnode.com/@alanmontgomery)

[Jan 18, 2021](https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3/comment/6005a6ab7b30c23b714ab5ff#reply-6005b2467b30c23b714ab6dd)

Yeah definitely could include that for people who are confused about modern-day SPA that don't actually "redirect" or "reset". I guess I just assumed that readers would understand the architecture and structure of Next (and React in that case) in terms of links and how you should not refresh your app, because of course, you will lose your state. The state is always available in any case until the page is refreshed.

Hopefully, this tutorial was then slightly helpful after all, and sorry if you found it unusable, however, I did try to cover what was needed.

[Pablo Bernal](https://hashnode.com/@bernalmurcia)

[Jan 18, 2021](https://hashnode.com/posts/using-react-context-api-with-nextjs/5f9f3de9de85d46a77d5ebe3/comment/6005a6ab7b30c23b714ab5ff#reply-6005d5e1848f4c3b9a0f1d57)

I'm still confused about how the state is stored across navigations. I'd think either you don't perform a full navigation or you store state in local/session storage. Which is it when using Context API on the app component?

Is the Context API somehow using local storage under the hood, abstracted from us, or does this only work when using NextJS as CSR and not when using SSG?

Edit: I understand now! The key is that even for SSG Nextjs actually performs a client-side navigation when using the Link component, instead of a full page refresh, as they mention in the docs for routing:

[nextjs.org/docs/routing/introduction](https://nextjs.org/docs/routing/introduction)

"The Next.js router allows you to do client-side route transitions between pages, similar to a single-page application.

A React component called Link is provided to do this client-side route transition."
