Coder Social home page Coder Social logo

marceloaugusto80 / react-ssr-express Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 3.0 257 KB

SSR template: Typescript + React + Router + Express + Persistent data

TypeScript 97.27% HTML 2.64% JavaScript 0.08%
ssr react typescript webpack express router boilerplate template jest supertest

react-ssr-express's Introduction

SSR: Typescript + React + Router + Express + Jest

React server side rendering with persistent server data

This template has the following main dependencies:


Instalation

  1. Clone the repo: https://github.com/marceloaugusto80/react-ssr-express.git
  2. Install dependencies:
$ npm install

Usage

Use one of the following commands:

  • run server in watch mode:
$ npm run start:server
  • run client app in dev server with Hot Reload:
$ npm run start:client
  • build the application for production:
$ npm run build:prod
  • test:
$ npm test

Compilation output

After compilation, all output will be available in the ./dist folder. The server logic will be bundled in the ./dist/app.js file and client assets will be in the ./dist/public/ folder.

Client vs Server side branching

The global variable __SERVER__ will be set to true if the code was compiled to target the server (Node) environment. Otherwise, it will have a value of false.

Prerendered data persistence

Check the following modules to see how server side data are passed and persisted in the prerendered dom:

./src/shared/PrerenderData.ts
./src/client/serverData.ts

The examples how to use these modules are in:

./src/server/middleware/routing.ts
./src/client/pages/SamplePage1.tsx

Any bug or improvement, please let me know.

react-ssr-express's People

Contributors

marceloaugusto80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.