Skip to content

sirshurak/create-react-app-with-ssr-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to create-react-app-with-ssr-example 👋

Version

Create React App with SSR example

This project show how to implement SSR with a simple React App project.

Do yourself

If you already have a project, I can help you. Just follow the above steps.

Separate React backend from frontend

Create a file index.ssr.jsx on src folder. This file will contain your StaticRouter.

Create your ambient for serve React

You can create a express server and then import your React string rendered by react-dom/server.

Building

Eject react-scripts

You will need to eject react-scripts because we will use webpack to generate server rendering build and it's easiest to create jest tests.

yarn eject

Create webpack for each ambient

First, create a webpack to deal with index.ssr.jsx as an entry, because you will need basically everything react-scripts does to render a React App. You can just copy the ejected config/webpack.config.js or import into your new webpack file. Then, change the entry of the webpack to index.ssr.jsx.

Commands

Install

yarn install

Usage

yarn start

SSR

yarn server

Run tests

yarn test

Author

👤 Vinicius Tonelli

Show your support

Give a ⭐️ if this project helped you!

Getting Started with Create React App

This project was bootstrapped with Create React App.


This README was generated with ❤️ by readme-md-generator

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published