- Node.js (v20 or later)
- pnpm (package manager)
- Create a new Next.js app:
pnpm create next-app@latest my-app
- Install required dependencies:
cd my-app pnpm install
- Configure Tailwind CSS:
pnpm exec tailwindcss init -p
- Update
tailwind.config.js
with the required plugins:
module.exports = { content: [ "./pages//*.{js,ts,jsx,tsx}", "./components//*.{js,ts,jsx,tsx}", ], theme: { extend: {}, }, plugins: [ require('@tailwindcss/forms'), require('@tailwindcss/typography'), require('tailwindcss-debug-screens'), ], }
- Update
styles/globals.css
with Tailwind directives:
@tailwind base; @tailwind components; @tailwind utilities;
- Configure Vitest:
pnpm exec vitest init
- Update
vitest.config.js
with the required setup:
import { defineConfig } from 'vitest/config' import react from '@vitejs/plugin-react'
export default defineConfig({ plugins: [react()], test: { globals: true, environment: 'jsdom', setupFiles: './test/setup.js', }, })
- Create
test/setup.js
and add the following code:
import '@testing-library/jest-dom/extend-expect'
- Configure Husky and lint-staged:
pnpm exec husky install pnpm pkg set scripts.prepare="husky install" pnpm exec husky add .husky/pre-commit "pnpm run lint:staged"
pnpm run dev
: Start the development serverpnpm run build
: Build the production versionpnpm run start
: Start the production serverpnpx serve@latest out
: Start the production server (foroutput:"exports"
mode)pnpm run lint
: Run the linterpnpm run format
: Format the codepnpm run test
: Run testspnpm run test:staged
: Run tests on staged filespnpm run lint:staged
: Run linter on staged files
Now you have a Next.js SPA set up with Biome.js, Vitest, Tailwind CSS, Husky, and lint-staged for linting, testing, and formatting your code on commit.