If you want to develop a client-side application with React, you will need some kind of a starter / boilerplate (provided — of course — configuring Webpack isn't your passion). You'd probably reach for Create React App being the most popular one.
It has some not-so-nice caveats though, including:
- no hot reloading by default (although it's comming in the v4)
- no way to configure / extend Babel config by design
- no way to configure / extend Webpack config by design
- cumbersome eslint workflow (if you use custom config, CRA will complain, and there's a good chance you'll get some errors you can do almost nothing about)
By using Next.js toolchain you can get the same benefits as CRA gives you, only without the caveats.
Plus you get:
- ability to prerender & export your react app as static HTML website (great for SEO)
- a clear path to Server-Side Rendering should you need it
and much more
For more information, I highly recommend reading Replacing Create React App with the Next.js CLI
This repo is a simple Next.js starter configured to redirect all requests to the index page, effectively behaving like a SPA. Read the official docs for more information.
Development:
npm run dev
to start the development environment
Production:
npm run build
- to build, bundle & export static filesnpm start
- to start a server to preview the build
Inspired by @tannerlinsley's gist and tweet and another tweet