-
Notifications
You must be signed in to change notification settings - Fork 91
Migrate to NextJS #324
Comments
wrouter replaced by @next/router |
@zachrbrown why is the I've just been using the |
@maelswarm — The last time I did an integration with Note this section of the Server Rendering guide in Redux's docs. The way tldr; state that is managed outside of Again, it has been a little while since the last time I an integration of the two things, so please let me know if you have evidence to the contrary! |
redux
)wouter
)chakra-ui
)Preface
There are a subset of features planned in OpenMinter's future which will either require or benefit from the project having server side capabilities.
Including, but not limited to:
While there aren't many React SSR solutions to choose from,
Next.js
is widely popular and generally the first choice for React SSR in the ecosystem.Next.js is an opinionated React framework which bakes in server-side-rendering (SSR), client/server side routing, a simple API tier, and it is well documented. Not least, it is fairly easy to add to an existing React project without too much migration pain. As such, it is a fairly obvious choice as a solution to address the above use cases.
Migration considerations
State management (
redux
)This codebase uses
redux
for state management. Given that theredux
store must be hydrated to render various bits of the application, it must necessarily be hydrated both server-side and client-side (and must be reconciled / kept in sync on both sides). Otherwise, we'll lose site crawlability for redux-connected pages and incur layout thrash (via irreconcilable server and client code rendering).This is nontrivial, as
redux
andNext.js
(or any SSR framework for that matter) do not implicitly interoperate. Fortunately,next-redux-wrapper
exists, and we can use this to simplify the integration. Again, given thatredux
doesn't simply "plug in" toNext.js
, it will still be required for the migrator to thoughtfully write the glue-code bits for everything to reconcile correctly.This will certainly be the most challenging bit of the migration.
Routing (
wouter
)This codebase uses
wouter
as its routing solution.Next.js
ships with its own routing solution. The app's routing will need to be migrated over entirely toNext.js
's routing system to leverage all of the SSR goodies. The routing in this application is dead simple, which should make for a really straight-forward migration.Styling (
chakra-ui
)Styling is handled via
chakra-ui
. In any SSR app which employs a css-in-js solution (likechakra
), ensuring styles are extracted and injected into server-side render results is critical to avoiding flash of unstyled content (FOUS) issues. Fortunately, this is trivial to do so withchakra
andnext.js
.Potential lack of module universality
There is always a possibility that a dependency isn't written to support both
node
andbrowser
APIs. However, it is fairly unlikely these days given the ubiquity of server-side-rendered javascript applications. This typically only arises in situations in which the relevantnode
andbrowser
APIs for some set of functionality wildly diverge — quite common in networking (e.g., http clients) or system level operations. Again, the probability is fairly low, but be on the lookout.The text was updated successfully, but these errors were encountered: