CRA and SSR ⚛️

2018-06-15 14:18:25

My favorite hierarchy for CRA with SSR 

After React released, many developers asked how we can make SSR SPA with React. After a while some developers tried to make a cli to create React with SSR skeleton but all of them failed because everything was changing in chaotic environment, for example react-router-dom introduces nested routes and grows so fast and also makes SSR more complex.

Right now many developers choose Zeit/Next.js for make SPA SSR but I do not prefer that cos:

-Next.js do not support react-router-dom (v4)

-Next.js forcing you to make app router into pages directory as a file (you can change it but it is so boring)

But I have to say that it so easy to use, But I don't prefer it.

I have a another solution specially when:

App->route->component->dispatch redux for async api

 My solution:

-Make your hierarchy like : App->route->component->PageSerivce*->call all needed data from api in async progress and after that dispatch redux for async api

 

I created an example that you can check it on Github.

Happy Hacking! 

Tags Cloud

React

Redux

SSR

CRA

create-react-app