NextJS project starter extended with tools to help you boost your development experience.
Help us improve by submitting suggestions and bug reports.
-
Create a NextJS app.
Straightforward project scaffold using degit.
npx degit https://github.com/MK-IT/nextjs-starter-essentials hello-world
Or alternatively, clone this repository.
git clone https://github.com/MK-IT/nextjs-starter-essentials hello-world
Navigate to your new app and install its dependencies.
# replace `yarn` with `npm` if it works better for you cd hello-world && yarn
Re-initialize Git and make an initial commit skipping pre-commit hooks.
rm -rf .git && git init && git add . && git commit -m "chore: initial commit" --no-verify
-
Configure.
Edit the default configuration of your new app if necessary.
package.json
.env
next-seo.config.js
next-sitemap.config.js
-
Develop..
Start the NextJS app in development mode.
# standard NextJS development mode yarn dev # Storybook development mode yarn storybook
Note: You can change the contents of
src/
in any way you like. Most pre-defined pages and components are for demo purposes only. -
Open the source code and start editing!
Your app is now running at
http://localhost:3000
!Open the project in your code editor of choice and edit
src/pages/index.tsx
. Save your changes and the browser will update in real time!
- πͺ Latest TS support
- π ReactJS + NextJS
- β‘οΈ ESLint, Prettier, EditorConfig
- π Storybook
- π§ͺ Jest + React Testing Library
- π
.env
configuration - π Clean folder structure
- π¦ Pre-commit hooks
- π€ Commit message linting
- π§π»ββοΈ Built-in
semver
automation - π VSCode configuration
- π Production ready
Checkout the feat/tailwind-css
branch for the same features but with Tailwind CSS included.
- β»οΈ Hygen templates
- π Filesystem linter
- π€ Sitemap + Robots.txt
- π SEO + JSON-LD
- π Aliased imports
- ποΈββοΈ Bundle Analyzer
- ...per-page layouts and more
You can provide environment variables to your app to customize its behavior in different environments. See the guide on environment variables.
Keep your commit messages human- and robot-readable using a shared convention, i.e. Commitlint.
Husky's Git hooks make sure that your commit messages follow the convention.
You can use Commitlint's CLI for fast authoring of your commit messages.
The package standard-version helps you generate CHANGELOG.md
, tag, and bump the version by following the semver convention.
The project maps several paths already as recommended in TypeScript path mapping docs.
# path aliases can be found in `tsconfig.json`
@root --> ./*
@pages --> src/pages/*
@layouts --> src/layout/*
@components --> src/components/*
# ...and more
// instead of...
import MyComponent from '../../../components/my-component';
// you can do...
import MyComponent from '@components/my-component';
Under the hood the feature uses NextJS + Webpack Bundle Analyzer to visualize the size of your bundle's output files.
The analyzer script (yarn analyze
) builds the project and generates static HTML reports.
You can find the generated reports under next/analyze/
.
# local development
yarn dev
# production build
yarn build
# serve production build
yarn start
# production build with bundle analyzer reporting
yarn analyze
# debug
yarn debug
# test
yarn test
# code generation with Hygen
yarn gen[:component | page | hook | utils | api]
# format code with Prettier
yarn format
# lint code with ESLint
yarn lint
# lint filesystem with ls-lint
yarn lint:fs
# semver, changelog, and release
yarn release
# build, test and explore UI components in isolation
yarn storybook
# build static Storybook site
yarn storybook:build
.
βββ .husky # VSCode workspace config
βΒ Β βββ commit-msg # commitlint messages
βΒ Β βββ pre-push
βββ .storybook # Storybook Configuration
β βββ main.js
β βββ preview.js
βββ .hygen # Hygen templates
βΒ Β βββ nextjs # NextJS API templates
βΒ Β βββ react # React templates
βββ .vscode # VSCode workspace config
βΒ Β βββ extensions.json
βΒ Β βββ launch.json
βΒ Β βββ settings.json
βββ src # Source code
βΒ Β βββ components
βΒ Β βββ hooks
βΒ Β βββ containers
βΒ Β βββ layout
βΒ Β βββ pages
βΒ Β βββ styles
βΒ Β βββ types
βΒ Β βββ utils
βββ public # Static assets
βΒ Β βββ images
βΒ Β βββ robots.txt
βΒ Β βββ sitemap.xml
βββ .commitlintrc.js
βββ .editorconfig
βββ .env # Default `dotenv` secrets
βββ .eslintrc.js
βββ .gitignore
βββ .ls-lint.yml
βββ .versionrc.js
βββ CHANGELOG.md
βββ jest.config.js
βββ jest.setup.js
βββ LICENSE
βββ next-env.d.ts
βββ next-seo.config.js
βββ next-sitemap.config.js
βββ next.config.js
βββ package.json
βββ README.md
βββ tsconfig.json
βββ yarn.lock
NextJS apps can be easily deployed to custom Node.js servers, as Docker images, static HTML exports, and Vercel (recommended).
For automated Vercel deployment and more on the topic refer to deployment guide.
It's highly recommended to build (or even yarn analyze
) and run your app before deployment as a local preview
Once ready and assuming your CI/CD is connected to your repository, you can run yarn release
to trigger a standard-version
release and follow the prompts π.