DEV Community

Discussion on: Context API with TypeScript and Next.JS

Collapse
 
itzsrikanth profile image
itzsrikanth

A very informative article.
But having one doubt of how context persists across different pages since NextJs does not act as a SPA?

Collapse
 
shareef profile image
Mohammed Nadeem Shareef

I am not sure but I think NextJS handles it under the hood, I have used context in NextJS projects and It was persists across different pages.

Collapse
 
muswain profile image
Mrutyunjay

As long as the provider is wrapped in the MyApp function in _app.tsx, it basically is available across pages. The provider is basically the parent of all components including all next.js pages in the way it is specified in _app.tsx file.