React JS Boilerplate

Guide

Install Dependencies

npm install

Environment Variables

All environment variables for react application must start with APP_ prefix

To change env prefix change add or remove string from envPrefix variable in vite.config.json

Environtment variables can be accesed using env.<name> or import.meta.env.<name>. Prefix must be included.

Declare env types in src/env.d.ts in ImportMetaEnv interface

The environment variables can be found and modified in the .env file. See .env for default values.

In the project directory, you can run:

Start

Start development build

npm start

Build

build for production.

npm run build

Preview

Preview production build

npm run preview

Clean

Removes all the files generated by the build process.

npm run clean

Lint Build

Rebuild eslint config from typescript source

npm run lint:build

Lint Check

Finds errors in your code.

npm run lint:check

Lint Fix

Fix linting errors.

npm run lint:fix

Lint Staged

Fix staged code linting errors.

npm run lint:staged

Prettier Fix

Fix the code formatting.

npm run prettier:fix

Prettier Check

Check the code formatting.

npm run prettier:check

Notes

  • tsconfig.json is for react app typescript configuration.
  • tsconfig.node.json is for vite and other development tools typescript configuration that will not be included in build result.
  • If you want to add pre-commit or pre-push git hook you can add the command to run in .husky/pre-commit and .husky/pre-push.
  • If you want to disable dependabot you need to remove .github/dependabot.yml.
  • If you want to disable codeql analysis you need to remove .github/workflows/codeql-analysis.yml.