Skip to content

MK-IT/nextjs-starter-essentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NextJS

NextJS Starter Essentials

NextJS project starter extended with tools to help you boost your development experience.

Help us improve by submitting suggestions and bug reports.

πŸš€ Getting Started

  1. 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
    
  2. Configure.

    Edit the default configuration of your new app if necessary.

    • package.json
    • .env
    • next-seo.config.js
    • next-sitemap.config.js
  3. 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.

  4. 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!

⭐ Features

Main features

  • πŸ’ͺ 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.

Extra features

πŸ›  .env configuration

You can provide environment variables to your app to customize its behavior in different environments. See the guide on environment variables.

🀝 Commit message linting

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.

:πŸ§—πŸ»β€β™‚οΈ: Built-in semver automation

The package standard-version helps you generate CHANGELOG.md, tag, and bump the version by following the semver convention.

πŸ‘‰ Aliased imports (Path Aliases)

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';

πŸ‹οΈβ€β™‚οΈ Bundle Analyzer

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/.

🧐 What's inside?

πŸ‘·β€β™‚οΈ Available Scripts

# 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

πŸ“‚ Folder Structure

.
β”œβ”€β”€ .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

πŸ’« Deploy

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 🏁.