Before you start reading, take a look at the running app that you get by cloning this repository:
You can kick off your custom project based on this boilerplate using the Forrest CLI:
npx forrest run project-name
What do I get?
You can quickly start to build a universal web app with:
- Configure your Webpack without ejecting thanks to react-scripts-rewired
- redux state manager
- Component based routing thanks to react-router
- Code splitting thanks to react-loadable
- Multilanguage support thanks to react-intl
- ExpressJS backend with a bounch of built in functionalities
- Node Hooks for a modular backend codebase
- GraphQL based API
- Conditional caching for all your routes
- Dockerfile ready to deploy your full application in a container
Your app will load in the client and in the server, you have a good deal of control about that.
In the project directory, you can run:
Builds and run the full app for production.
- Your client (
/src) is bundled by CRA
- Your client (
/src) is transpiled for SSR
- Your server (
/ssr) is transpiled for SSR
- Localized strings are estracted from your app's source
npm run start:dev
Builds and starts both API and CRA app in a single command.
- http://localhost:3000 serves the Webpack Dev Server as provided by CRA
- http://localhost:8080 serves the SSR app
- http://localhost:8080/api serves the GraphQL development interface
npm run build
Builds the app for production to the
This is needed for SSR to work properly.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
npm run lint
eslint check in your terminal.
Useful to integrate with CI tools.
ESLint should also work just fine with your IDE. I use VSCode and I'm happy.
npm run styleguide
Runs the react-styleguidist examples in a frontend project that does not require the entire app running.
Take a look at
./styleguide.config.js to learn how to add components to it and
how to hack it so to match your app's needs.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
To learn ForrestJS and React Server Side Rendering, check out the ForrestJS documentation.
Copyright 2019 Marco Pegoraro
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.