/nextjs-template

一个 Next.js 开发模板,集成 TypeScript, TailwindCSS, ESLint, Prettier, Husky git hooks.

Primary LanguageTypeScript

Next.js

Next.js Starter Template

A Minimal Next.js Starter Template with TypeScript, Tailwind CSS, and pre-configured with ESLint, Prettier, and Husky.

Features

  • Next.js - A React Framework for Production
  • 🔥 App Router - It is a new paradigm for building applications using React's latest features.
  • 🎨 Tailwind CSS - A Utility-First CSS Framework for Rapid UI Development
  • 📦 TypeScript - A typed superset of JavaScript that compiles to plain JavaScript
  • 📝 ESLint - The pluggable linting utility for JavaScript and JSX
  • 🛠 Prettier - An opinionated code formatter
  • 🐶 Husky - A tool that makes Git hooks easy
  • 🚫 lint-staged - Run linters against staged git files
  • 📄 commitlint - Lint commit messages
  • 📦 bun - A JavaScript runtime w/ Fast, disk space efficient package manager

Getting Started

bun create next-app -e "https://github.com/liaoyio/nextjs-template" <project-name>

npx create-next-app -e "https://github.com/liaoyio/nextjs-template" <project-name>

OR

Install degit globally

bun i -g degit || pnpm i -g degit || yarn global add degit || npm i -g degit

Create a new project from this template

degit liaoyio/nextjs-template <project-name>
cd <project-name>

Install dependencies

bun i || pnpm i || yarn || npm i

Initialize a new git repository (Optional):

git init
git add .
git commit --no-verify -m "init"

Available Scripts

In the project directory, you can run:

Script Description
dev Runs the app in the development mode.
build Builds the app for production to the .next folder.
start Runs the built app in the production mode.
preview Builds and serves the app in the production mode.
lint Runs next lint on the project.
type-check Runs TypeScript type checker.
fmt Formats the code with Prettier.
fmt:check Checks if the code is formatted with Prettier.
prepare Installs husky git hooks.
lint:lint-staged Runs lint-staged
commit Runs git-cz

Switching Package Manager

This template uses bun as the default package manager. If you want to use pnpm, npm or yarn, you need to remove the bun.lockb file and run pnpm i, npm i or yarn to generate the lock file for the respective package manager.