Git Product home page Git Product logo

react-typescript-express-ssr-example's Introduction

React TypeScript Express SSR example

React ssr exmaple with typescript, babel, css-modules, react-router, redux, redux-thunk, ramda, webpack 4.

Commitizen friendly

You can read more about the organizational strategy used in this app in this Medium post, or this post.

Contains

Aliases

  • @client/* resolves to ./src/client/*
  • @server/* resolves to ./src/server/*
  • @core/* resolves to ./src/core/*

Routing

Routes in project are objects with the same properties as a <Route> with a couple differences:

  • the only render prop it accepts is component (no render or children)
  • introduces the routes key for sub routes
  • introduces the preloadActions key for preFetch on server
  • Consumers are free to add any additional props they'd like to a route, you can access props.route inside the component, this object is a reference to the object used to render and match.
  • accepts key prop to prevent remounting component when transition was made from route with the same component and same key prop
const routes = [
  {
    component: Root,
    preloadActions: someAction('someProp'), // preloadActions: {type: 'someAction', payload: someProps}
    routes: [
      {
        path: '/',
        exact: true,
        component: Home,
        preloadActions: [someAction('someProp'), someSecondAction('someProps')]
      },
      {
        path: '/child/:id',
        component: Child,
        routes: [
          {
            path: '/child/:id/grand-child',
            component: GrandChild
          }
        ]
      }
    ]
  }
];

Note: Just like <Route>, relative paths are not (yet) supported. When it is supported there, it will be supported here.

Using CSS

It uses the usual SCSS css modules. You can find more information here

Render instead of hydrate in development mode

To be able to reload the page and see the latest code changes, you must set the "localStorage.useRender" value in development mode (the hydrate method will be replaced with the render)

Setup

$ npm install

Running

Start express development server

$ npm run start

Build

Build client for production

$ npm run build:client

Build server for production

$ npm run build:server

Or simply

$ npm run build

Build server and client for production

Analyze

Vendors Size (all node_modules)

$ npm run analyze:vendors

Bundle Size (all exclude node_modules)

$ npm run analyze:bundle

Or simply

$ npm run analyze

To see the size and bundle and vendors

react-typescript-express-ssr-example's People

Contributors

afflicted-cat avatar dependabot[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

react-typescript-express-ssr-example's Issues

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.