Awesome Open Source
Awesome Open Source

Starter Pack

Overview

Starter Pack combines React, Redux and Redux-saga with Auth0's Lock as a starting point for modern web apps with solid authentication. Why reinvent the wheel? The app utilises Rebass and Reflexbox to keep things looking decent. I built this as a way to quickly prototype new ideas.

Webpack (ft. various loaders/plugins/tools) is used to run a local development server and build the production version. Code splitting (with long-term caching in the production version) has been set up via Webpack and React Loadable. Webpack's CommonsChunkPlugin is used to split vendor code. React Loadable is used for async component-centric code splitting and loading - see LoadableBooksPage.js as an example of creating a split point (restart the dev server if the new chunk is not emitted). ExtractTextPlugin is used to split CSS. HtmlWebpackPlugin is used to generate an index.html with the appropriate output assets injected, the Webpack manifest is inlined into index.html to save requests.

The app contains a 'locked down' Books page which requires a user to log in/sign up before content will be visible. The data is read from a local JSON file as this is a only demonstration/starting point. In the real world data would be fetched from an API - see apiService.js. Protected routes in the API should check validity of the JWT token and return unauthorised if invalid. The app should then prompt the user to log in again. See [Serverless API] (https://awesomeopensource.com/project/jch254/serverless-node-dynamodb-api) for a more detailed example of authentication in action.

I've also created a branch that utilises TypeScript for type checking and transpliation to browser-friendly ES5 JavaScript.

Main

Modal

Recommended

Tools Used

AUTH0_CLIENT_ID and AUTH0_DOMAIN environment variable must be set before yarn run commands below.

E.g. AUTH0_CLIENT_ID=YOUR_CLIENT_ID AUTH0_DOMAIN=YOUR_DOMAIN yarn run dev

Running locally (with hot reloading)

  1. Sign up and create a new Auth0 app
  2. Add http://localhost:3001 as an Allowed Origin (CORS) for your newly created app (don't forget to press save)
  3. Run the following commands in the app's root directory then open http://localhost:3001
yarn install
yarn run dev

Running development version locally in Docker container

  1. Run the following commands in the app's root directory then submit requests to http://localhost:3001.
docker build -t starter-pack .
docker run -p 3001:3001 -e AUTH0_CLIENT_ID=YOUR_CLIENT_ID -e AUTH0_DOMAIN=YOUR_DOMAIN starter-pack

Building the production version

  1. Run the following commands in the app's root directory then check the /dist folder
yarn install
yarn run build

Running production version locally

  1. Run the following commands in the app's root directory then open http://localhost:3001
yarn install
yarn run prod

Deployment/Infrastructure

Refer to the /infrastructure directory.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Typescript (251,877
Reactjs (72,368
Redux (13,194
Webpack (9,736
Authentication (3,909
Starter Kit (1,401
Redux Saga (1,336
Auth0 (545
Code Splitting (241
Related Projects