All Projects โ†’ hiroppy โ†’ Ssr Sample

hiroppy / Ssr Sample

A minimum sample of Server-Side-Rendering, Single-Page-Application and Progressive Web App

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ssr Sample

Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: โœญ 141 (-50.53%)
Mutual labels:  graphql, webpack, babel, styled-components, server-side-rendering
Crate
๐Ÿ‘• ๐Ÿ‘– ๐Ÿ“ฆ A sample web and mobile application built with Node, Express, React, React Native, Redux and GraphQL. Very basic replica of stitchfix.com / krate.in (allows users to get monthly subscription of trendy clothes and accessories).
Stars: โœญ 2,281 (+700.35%)
Mutual labels:  graphql, webpack, babel, ssr, server-side-rendering
React App
Create React App with server-side code support
Stars: โœญ 614 (+115.44%)
Mutual labels:  graphql, webpack, babel, ssr, server-side-rendering
React Firebase Starter
Boilerplate (seed) project for creating web apps with React.js, GraphQL.js and Relay
Stars: โœญ 4,366 (+1431.93%)
Mutual labels:  graphql, ssr, styled-components, spa, server-side-rendering
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: โœญ 1,833 (+543.16%)
Mutual labels:  graphql, apollo, webpack, ssr, server-side-rendering
Pizzaql
๐Ÿ• Modern OSS Order Management System for Pizza Restaurants
Stars: โœญ 631 (+121.4%)
Mutual labels:  graphql, apollo, babel, ssr, styled-components
Laravel Vuejs.com
Laravel and VueJs Blog, using Laravel nova, GraphQL, NuxtJs, Apollo and ...more
Stars: โœญ 54 (-81.05%)
Mutual labels:  graphql, apollo, pwa, ssr, spa
React Starter Kit
React Starter Kit โ€” front-end starter kit using React, Relay, GraphQL, and JAM stack architecture
Stars: โœญ 21,060 (+7289.47%)
Mutual labels:  graphql, webpack, babel, ssr
Twreporter React
twreporter site with nodejs
Stars: โœญ 263 (-7.72%)
Mutual labels:  webpack, babel, pwa, server-side-rendering
Razzle Material Ui Styled Example
Razzle Material-UI example with Styled Components using Express with compression
Stars: โœญ 117 (-58.95%)
Mutual labels:  webpack, ssr, styled-components, server-side-rendering
Cookiecutter Django Vue
Cookiecutter Django Vue is a template for Django-Vue projects.
Stars: โœญ 462 (+62.11%)
Mutual labels:  graphql, apollo, webpack, pwa
Pup
The Ultimate Boilerplate for Products.
Stars: โœญ 563 (+97.54%)
Mutual labels:  graphql, apollo, ssr, styled-components
Vuesion
Vuesion is a boilerplate that helps product teams build faster than ever with fewer headaches and modern best practices across engineering & design.
Stars: โœญ 2,510 (+780.7%)
Mutual labels:  webpack, server-side-rendering, pwa, apollo
React Hipstaplate
A ReactJS full-stack boilerplate based on typescript with ssr, custom apollo-server and huge stack of modern utilities which will help you to start your own project
Stars: โœญ 74 (-74.04%)
Mutual labels:  graphql, apollo, styled-components, redux-saga
Rpg Boilerplate
Relay (React), Postgres, and Graphile (GraphQL): A Modern Frontend and API Boilerplate
Stars: โœญ 62 (-78.25%)
Mutual labels:  graphql, webpack, ssr, server-side-rendering
Tkframework
react + relay + redux + saga + graphql + webpack
Stars: โœญ 83 (-70.88%)
Mutual labels:  graphql, webpack, babel, redux-saga
Award
โš™ๅŸบไบŽreact็š„ๆœๅŠก็ซฏๆธฒๆŸ“ๆก†ๆžถ
Stars: โœญ 91 (-68.07%)
Mutual labels:  webpack, babel, ssr, spa
Reeakt
A modern React boilerplate to awesome web applications
Stars: โœญ 116 (-59.3%)
Mutual labels:  webpack, ssr, styled-components, redux-saga
Meteor Apollo Starter Kit
Meteor, Apollo, React, PWA, Styled-Components boilerplate
Stars: โœญ 91 (-68.07%)
Mutual labels:  graphql, apollo, pwa, styled-components
Preact Redux Isomorphic
preact-redux-isomorphic PWA SPA SSR best practices and libraries in under 80kB page size (for live demo click the link below)
Stars: โœญ 85 (-70.18%)
Mutual labels:  graphql, pwa, ssr, spa

A minimum sample of Server-Side-Rendering, Single-Page-Application, and Progressive Web App

What's this project?

This project introduces how to implement SSR, SPA, and PWA.

Articles

only Japanese

Feature

This project shows several implementations like below.

  • Server Side Rendering
  • Single Page Application
  • Progressive Web App
  • GraphQL
  • RESTful API
  • Security (CSP, GraphQL)
  • Testing
  • Infra like the building tools
  • Measuring performance

Libraries

Dependencies

Name Purpose CSR SSR Note
react view yes yes
redux architecure yes yes
react-router routing yes yes
react-helmet head tag yes yes
redux-saga side effects yes yes
styled-components CSS in JS yes yes
loadable-components dynamic import yes yes
apollo-boost GraphQL yes yes
express server side framework N/A yes
nanoid Creating a random hash N/A N/A

DevDependencies

Name Purpose Note
typescript Alt
webpack a bundler for client side
babel transpile typescript and loadable-components
storybook preview
storyshots snapshot tests
jest test runner
testing-library a helper to test react
nodemon a watcher for server side
prettier formatter
typescript-eslint linter
workbox service worker
clinic performance profiling
autocannon benchmarking tool

Pages

See the router: src/client/router/.

This application has 3 pages and creates SPA based on redux and redux-saga.
Saga page and Apollo page use same components so you can compare each implementation.

Top

This page reads README.md using babel-plugin-macro.

src: src/client/components/pages/Top

Saga

This page runs just redux-saga application.

page src: src/client/components/pages/Saga

Apollo

This page runs just apollo application.

page src: src/client/components/pages/Apollo

Control SSR and SPA

design concept: gist
src: src/client/sagas/pages.ts

All pages fork saga processes.

  • appProcess
    • a common processing to execute on all pages(e.g. confirming login, sending to GA, etc...)
  • pages
    • loadTopPage, loadingApolloPage
      • just stop saga when it ran at a server
    • loadSagaPage
      • fetching data and then stopping if it ran at a server

appProcess and pages run in parallel, also they run the same code in a server and client.

Need to call END when running on Node.js

If you do SSR using redux-saga, you have to stop redux-saga process when all processes are finished.

try {
  // fetch...

  yield put(success());
} catch (err) {
  yield put(failure(err));
} finally {
  if (!process.env.IS_BROWSER) {
    yield put(END);
  }
}

Global Variables

src: src/server/controllers/renderer/renderer.tsx.

Use the following variables to pass data acquired by a server to the client side.

data-json

This script tag has state and data which are fetched via redux-saga, etc at the server.

<script id="initial-data" type="text/plain" data-json=...></script>.

window.__APOLLO_STATE__

This variable has GraphQL data which are fetched at the server.

Lighthouse

lighthouse

If you want to get 100 point for Best Practices, you need to set a reverse proxy server like Nginx because Express hasn't implemented http/2 yet.(also Performance)

Setup

$ git clone [email protected]:hiroppy/ssr-sample.git
$ cd ssr-sample
$ npm i

Development

$ npm start
$ open http://localhost:3000

# GraphQL Playground
$ open http://localhost:3000/graphql

Storybook

$ npm run start:storybook
$ open http://localhost:6006

Test

$ npm test

Production

$ npm run build             # npm run build:client + npm run build:server
$ npm run start:prod        # run server and use 3000
$ open http://localhost:8080

Deploy

$ npm run deploy:storybook

Performance

$ npm run build
$ npm run start:prod
$ npm run benchmark # rps

Running 10s test @ http://localhost:8080
100 connections

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Stat    โ”‚ 2.5%   โ”‚ 50%    โ”‚ 97.5%  โ”‚ 99%     โ”‚ Avg       โ”‚ Stdev     โ”‚ Max        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Latency โ”‚ 161 ms โ”‚ 406 ms โ”‚ 829 ms โ”‚ 1277 ms โ”‚ 413.26 ms โ”‚ 191.69 ms โ”‚ 2649.38 ms โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Stat      โ”‚ 1%      โ”‚ 2.5%    โ”‚ 50%     โ”‚ 97.5%   โ”‚ Avg     โ”‚ Stdev  โ”‚ Min     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Req/Sec   โ”‚ 210     โ”‚ 210     โ”‚ 233     โ”‚ 264     โ”‚ 236.6   โ”‚ 18.87  โ”‚ 210     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Bytes/Sec โ”‚ 3.16 MB โ”‚ 3.16 MB โ”‚ 3.51 MB โ”‚ 3.98 MB โ”‚ 3.56 MB โ”‚ 284 kB โ”‚ 3.16 MB โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Req/Bytes counts sampled once per second.

$ npm run benchmark:flame # flamegraph

flamegraph

Note

This repository shows how to write and so does not introduce Atomic Design.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].