Live example on GitHub Pages (static site generation) and Cloudflare Pages (edge-side rendering)
This is an experimental starter kit for a React universal/isomorphic app.
- React Router
- CSS Modules + PostCSS + PurgeCSS + StyleLint
- TypeScript + ESLint
- Jest/React Testing Library for unit testing
- Playwright for E2E testing
- webpack
- Docker config
- nodemon + Hot module replacement (in development)
- Custom i18n solution using
sprintf-js
- Building for Express with server-side rendering
- Building for Cloudflare Pages with edge-side rending
- Building for a static app with prerendering (example on GitHub Pages)
- Data prefetching and caching
- Web workers
- CI/CD workflows with GitHub Actions
- Code quality analysis with SonarQube
# Install dependencies
$ npm install
# Run in development (client only)
$ npm run dev:static
# Run unit tests
$ npm run test:unit
In any of the build
or build:*
scripts, you can add the following arguments for additional diagnosis details of the build process:
# Analyzes the size the generated bundle(s) and displays a visual report in the default browser
$ npm run build:server --analyze
# Omits HTML/CSS/JS compressions during build
$ npm run build:server --raw
See scripts
in package.json
for additional commands.
This is the default behavior, simply run:
$ npm run build
You can then test it locally:
$ npm start
To build for Edge, run:
$ npm run build:edge
You can then test it on Cloudflare:
$ npm run start:edge
To export this app as a static site, run:
$ npm run build:static
This removes all server components from the built server app and generates static HTML files for all pages outlined in the /sitemap.xml
endpoint.
To test, run:
$ npm run start:static
Unit tests reside in /src
and can be ran via:
$ npm run test:unit
End-to-end tests are executed directly from the tests/
directory in TypeScript and requires the app to have already been built (i.e. build/
directory is not empty):
$ npm test
Building a containerized version of the app using the included Dockerfile
:
# Build the image
$ npm run ship:build
# Run the image
$ npm run ship:run
When using react-isomorphic-starter-kit
as a template, follow these steps to strip placeholder content:
- Replace
LICENSE
file - Edit
README.md
- Edit fields in
package.json
- Edit fields in
src/app.conf.ts
- Edit resources in
res/
, then ensure to replace the generated assets insrc/static/
- Edit files in
src/ui/
- Edit translations in
src/locales/
- Removed styled-components in favor of CSS modules
- Removed Redux in favor of Context API
- Updated how assets are imported
- Relocated
locales
directory - Created reusable workflows for CI/CD
- Added interactors
- Added
I18nProvider
- Decoupled boilerplate architectural code to
src/base
- Restructured folders
- Moved boilerplate code to
lib/
- Replaced
react-helmet-async
with custom solution inlib/