/react-starter

Full-featured typescript starter for React application

Primary LanguageTypeScriptMIT LicenseMIT

React Starter

Master CI Status Netlify Status

Getting Started

Just clone the repo with git clone https://github.com/Kamahl19/react-starter.git or click on "Use this template" button above.

Master branch is always passing CI build and it's deployed online at https://react-starter-ts.netlify.com

Keeping up with updates

Once you start building your own app on top of React Starter you will probably want to keep up-to-date with the new updates of React Starter. This can be easily achieved by tracking the latest commit hash of React Starter you use. We suggest this process:

  1. When you clone the React Starter repo, don't forget to write down the hash of latest master's commit
  2. Every once in a while, compare the version of React Starter you used with the current version of React Starter like this https://github.com/Kamahl19/react-starter/compare/{YOUR_LATEST_REACT_STARTER_COMMIT_HASH}...master
  3. Go through the diff and apply the changes in your own app
  4. Commit these changes into your own repo with this commit message: Updating to React Starter hash: {LATEST_REACT_STARTER_COMMIT_HASH}. This way you always keep the hash of the React Starter's version you currently use in your app

What’s Inside?

Start app

To run app locally, run yarn start in app root directory. react-scripts will start web server in the development mode at http://localhost:3000 (or first next free port).

All the Auth functionality such as Sign-up, Login, Reset password etc. requires a backend app. You can either write your own or use the Node API Starter which works with React Starter out of the box.

Build app

To build the app for production, run yarn build in app root directory. Your app is then ready to be deployed! See the create-react-app Deployment docs for more information.

Test app

Run yarn test to launch the test runner in the interactive watch mode. See create-react-app Tests docs for more information.

Project structure

-| .github/: GitHub workflows for CI/CD
-| public/: Public assets
-| src/
 |--| app/: Main application (framework) files.
 |--| common/: Base components, services, utils, rules, enums etc. used in the whole app.
 |--| features/: Features bundled into separate modules including components, screens, ducks, apis etc.
 |--| index.tsx: application entry file
-| storybook/: Storybook configuration and addons.

Prettier

This project uses Prettier, an opinionated code formatter. In order to format code manually, run yarn format in app root directory. All the code is also formatted automatically on pre-commit hook. There is also yarn format-check for CI purposes to check if code is formatted properly.

ESLint

Project comes with ESLint configured. It helps you prevent common errors.

There are multiple ways how to run ESLint.

  • CLI: yarn lint
  • in browser console while developing (after running yarn start)
  • it runs automatically on pre-commit hook
  • in IDE if supported (Visual Studio Code supports reports)

Storybook

We suggest developing components in isolation. For this reason, project comes with Storybook pre-configured.

To run separated development environment, run yarn storybook which will start dedicated web server at http://localhost:9009.

To build static storybook, run yarn storybook:build. This creates a static webpage which you can deploy and showcase your components to others.

More information about supported features can be found in Storybook's Github repository

i18n

Running yarn extract-translations will update alphabetically sorted JSON files with key-translations pairs. It will use default messages for keys without explicit translations.

Analysing production JS bundle

Project comes with the source-map-explorer which analyzes the production JS bundle. To use it just run yarn analyze.

Updating dependencies

Project comes with the default Renovate config renovate.json. It takes care of automated dependency updates and it's free for open-source projects. More about how to configure here.

CI/CD

This project is using GitHub's Actions to run integration tests on each PR and Master branch. It includes running eslint, prettier, tests and building the app. PR becomes mergable only if it passes. We also show badge on top of README.md to show Master branch status. If you don't use GitHub you can remove the .github folder, otherwise follow these steps to configure your GitHub repository:

  1. Go to Settings -> Branches -> Add rule
    • Apply to your master branch
    • Require status checks to pass before merging
    • Select build checks being run in CI.yml
  2. Update path to your repository (eg. Kamahl19/react-starter) and name of the branch for CI badge in README.md

This project is using Netlify to deploy each PR and Master branch automatically. If you don't use Netlify you can remove the netlify.toml file, otherwise follow these steps to setup Netlify:

  1. Follow Netlify's instructions
  2. Update Netlify status badge in README.md according to these instructions

More Docs & Guides

This project is built on top of create-react-app with many more usefull guides.

License

This is open source software licensed as MIT.