Support Next.js app router
Frikki opened this issue · 5 comments
Does the data-client support Next.js’s new app router? I notice that the guide is for the old pages router.
Unfortunately this will never be possible as app router is not built for what pages router is built for. Context and state do not work, because it is more of a templating system for static sites.
As long as they continue supporting the pages router that method will continue to work and even have the React 18 advantages. Alternatively if you want a framework more focused on SSR rather than SSG you could also try anansi. If you're aware of another framework that does SSR rather than SSG I'm happy to bring its integration into the fold.
Context and state do not work, because it is more of a templating system for static sites.
NextJS app router supports both server components (RSC) and client components. NextJS uses the "use client"
directive to make a component a client component. So, it is possible to use Context and state.
Here’s an article that shows how.
If you aren't trying to do anything server-side, can you clarify what issues you're running into? I ask because 'use client' is present in the code with context:
https://github.com/reactive/data-client/blob/master/packages/react/src/components/CacheStore.tsx#L3
https://github.com/reactive/data-client/blob/master/packages/react/src/hooks/useController.ts#L4
@Frikki See if https://github.com/reactive/data-client/releases/tag/%40data-client%2Freact%400.9.6 works? If not, if you could include whatever error message or relevant information that would be helpful to trace down the issue.