Using redux-api with Next.js next-redux-wrapper for server-side rendering?
See original GitHub issueAnyone tried using redux-api with Next.js for server-side rendering?
I’d like to get tips on how to do the initial redux-api sync()
call inside getInitialProps
(Next.js specific method) instead of componentDidMount
(as in the example), to get the data rendered server-side along with the first page request.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Server Side Rendering - Redux Toolkit
RTK Query supports Server Side Rendering (SSR) with Next.js via rehydration in combination with next-redux-wrapper.
Read more >How to integrate Redux — with Next.js and SSR
First of all, we need to create our redux store using the “createStore” function provided by the Redux Toolkit. nextRepo: nextSlice,
Read more >I want to use Redux with Next.js and do Server-Side ... - Reddit
Create a Redux store on the server side for every incoming request. Dispatch some actions and set up initial data while rendering the...
Read more >Server-Side Rendered App with Next.js, React and Redux
Next -redux-wrapper will enable us to create a store at every new request and it will pass it to MyApp (Our App Implementation)...
Read more >How to use Redux in Next.js - LogRocket Blog
The payload of this action will contain the state at the moment of static generation or server-side rendering, so your reducer must merge...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a complete working example of Next.js,
redux-api
, andnext-redux-wrapper
working in harmony:https://github.com/tomsoderlund/nextjs-express-mongoose-crudify-boilerplate
Just to follow up my own question: I ended up creating a (kind of?) singleton class for ReduxApi that has a setter for handing in the database connection instance. This database class variable can then be used by the custom adapter, deciding whether to fetch from the API or database and using the connection instance to query the database.
Like so