My personal, full-fledged react starter that is also suitable for enterprise use
Go to file
2022-11-08 21:35:48 +01:00
.husky eslint now receives the glob itself 2022-08-08 14:48:59 +02:00
.vscode Added styled components 2022-08-08 14:08:16 +02:00
config - Updated to React 18 2022-06-27 16:41:03 +02:00
cypress Added login command for cypress and SSO protected pages 2022-08-25 14:10:46 +02:00
public Added react-oidc (use demo/demo) 2022-07-26 11:15:36 +02:00
scripts added cypress 2022-06-27 18:04:55 +02:00
src Added CypressStrictMode 2022-08-15 11:51:40 +02:00
.babelrc - Updated to React 18 2022-06-27 16:41:03 +02:00
.browserslistrc - Updated to React 18 2022-06-27 16:41:03 +02:00
.dockerignore - Updated to React 18 2022-06-27 16:41:03 +02:00
.editorconfig - Updated to React 18 2022-06-27 16:41:03 +02:00
.eslintignore - Updated to React 18 2022-06-27 16:41:03 +02:00
.eslintrc added cypress eslint config 2022-07-07 14:10:41 +02:00
.gitignore ignore oidc fetch stuff 2022-08-30 13:47:13 +02:00
.nvmrc Added the possibility to override partial configs during deployments 2022-07-25 10:13:47 +02:00
.prettierrc.js - Updated to React 18 2022-06-27 16:41:03 +02:00
CHANGELOG.md Added login command for cypress and SSO protected pages 2022-08-25 14:10:46 +02:00
cypress.config.ts Added login command for cypress and SSO protected pages 2022-08-25 14:10:46 +02:00
Dockerfile - Updated to React 18 2022-06-27 16:41:03 +02:00
jest.config.js Added the possibility to override partial configs during deployments 2022-07-25 10:13:47 +02:00
package-lock.json chore: update dependencies 2022-11-08 21:35:48 +01:00
package.json chore: update dependencies 2022-11-08 21:35:48 +01:00
README.md Merge branch 'Mastermindzh:master' into master 2022-07-25 11:22:28 +02:00
tsconfig.json - Updated to React 18 2022-06-27 16:41:03 +02:00

react-starter-kit

Web project starter kit including modern tools and workflows based on create-react-app and best practices from the community. Provides a scalable base template and a good learning base. Suitable for enterprise usage

Includes:

  • Redux-toolkit
  • Vscode setup (debugging + snippets)
  • Jest, @testing-library and Cypress
  • Immer

Table of contents

Getting started

  1. npm install
  2. npm start (localhost:3000)
  3. npm test (run jest + coverage on localhost:8080)

Project structure

Only the important files are shown

.
├── .vscode # vscode setup (debug, snippets, etc)
├── config # tool configuration
├── cypress # e2e tests
├── dist # production version
├── public
├── public # directory with public files (config, icons, etc), will be copied to dist
│   ├── i18n # directory to house i18n language files
│   ├── config.js # default runtime application config
│   └── configOverride.js # default config overrides.
├── scripts # Modified default create-react-app scripts
├── src # application source
│   ├── app # redux-toolkit hooks + store
│   └── infrastructure # infrastructure code (wrappers, navigation, config file class)
├── CHANGELOG.md # update this whenever you update the application
├── Dockerfile # Dockerfile to build nginx container
├── jest.config.js # configuration for jest
├── package.json
├── README.md # keep this up to date
└── tsconfig.json

"Forking" outside of Github

To use this base in other git software (not Github) you will have to manually manage the upstream. Go into your existing repo and execute the following commands:

  1. git remote add upstream <clone-url>
  2. git pull upstream master # or other branchname
  3. git push

Then, when you need to sync again you can repeat step 2 and 3

Configuration

This starter kit comes with runtime configuration out-of-the-box. It achieves this with 2 config files in the public directory: config.js and configOverrides.js. config.js is meant to be filled with a default for all of your application's runtime configurations. configOverrides.js is meant to be replaced during deployment with environment specific runtime overrides.

Using the config.ts file

To use the config you import Config from config.ts and use the typed object:

import { Config } from "../config";

import { FunctionComponent } from "react";

export const Navbar: FunctionComponent<{}> = () => {
  return <h1>{JSON.stringify(Config)}</h1>;
};

adding values

To add a value to the runtime config you have to take 2 steps:

  1. Add a type to the RuntimeConfig type in src/infrastructure/config/RunTimeConfig.ts

    type RunTimeConfig = {
      version: number;
      name: string;
      myNewKey: string;
    };
    
  2. Add a key (if required) to public/config.js