Hello and welcome to NextJS template
This is a template for NextJS with TailwindCSS, TypeScript, i18n, Jest, Zod, React Hook Form, shadcn/ui and more!
Next.js Template
Welcome to the Next.js Template project! This template is designed to be the ideal starting point for your modern Next.js applications, streamlining the development process right from the get-go.
š Quick Start
Getting started with this Next.js template is straightforward. Follow these steps to create your new project using this template:
-
Create a new Next.js app using this template:
Run the following command in your terminal to create a new project with this template:
npx create-next-app@latest your-project-name --example https://github.com/zerodays/nextjs-template -
Navigate into your new project folder:
cd your-project-name -
Install dependencies:
pnpm i -
Run the development server:
pnpm dev
š§ What's Included?
- Next.js 16 with App Router
- TailwindCSS for styling
- Exposes styles as global CSS variables and theme object
- Includes plugins like tailwindcss-animate, tailwindcss/typography, and tailwind-scrollbar
- Biome.js for formatting and linting
- Replaces ESLint and Prettier
- Configured for accessibility, correctness, and custom formatting
- Automatically organizes imports
- Orval for generating API clients from OpenAPI specs
- Configured to use
react-queryfor API calls - Supports mocking and integration with Biome.js
- Configured to use
- React Hook Form for forms
- Zod for form validation
- Git Hooks with Husky for:
- commitlint for conventional commits
- lint-staged for staged changes
- VS Code Settings for consistent development environment
- Auto format and fix on save with Biome.js
- Prioritize non-relative imports
- Internationalization using next-international
- Server-side:
await getScopedI18n('fileName') - Client-side:
useScopedI18n('fileName')
- Server-side:
- Type-safe Environment Variables with t3-oss/env-nextjs
- Sentry for error/event tracking
- Shadcn/UI setup for reusable components
- Utility Hooks for common tasks
š Project Structure
Here's an overview of the folder structure provided in this template:
.
āāā .github # GitHub Actions configurations for CI/CD + PR template
āāā .husky # Husky configurations for managing Git hooks
āāā .vscode # VSCode settings to maintain consistency in development environments
āāā docs # Extended documentation and guides
āāā public # Stores static files like images and fonts
āāā scripts # Custom scripts for development tasks like API generation
āāā src # Source files for the Next.js application
ā āāā api # API clients generated by Orval
ā āāā app # Core application files including pages and API routes
ā āāā components # Reusable UI components
ā āāā i18n # Internationalization configurations
ā āāā lib # Utility functions and custom hooks
ā āāā env.ts # Type-safe environment variable configuration
ā āāā middleware.ts # Custom middleware functions
āāā README.md # The main README file for the project
š§ Configuration
š Biome.js Configuration
Biome.js replaces ESLint and Prettier, offering formatting, linting, and organizing imports in one tool. Key configurations include:
- Custom rules for accessibility, correctness, and complexity
- Automatic import organization
- Custom formatting styles for JavaScript, TypeScript, and CSS
Configuration file: biome.jsonc
Run the formatter and linter:
pnpm format
pnpm lint
š” Orval Configuration
Orval generates react-query clients from OpenAPI specs. It is set up to:
- Fetch the OpenAPI spec from a deployed URL
- Split the output into endpoints and schemas
- Enable mocking for local development
- Integrate with Biome.js for consistent formatting
API client generation script: scripts/generate-api.ts
Run the script:
pnpm gen-api
š Environment Variables
Environment variables are managed with t3-oss/env-nextjs for type safety. Update src/env.ts to define and validate variables.
š¦ TailwindCSS
TailwindCSS is fully configured with plugins for animations, typography, and custom scrollbars. Customize tailwind.config.ts to extend themes or add plugins.
š Internationalization
Add languages in src/i18n and update i18n.ts to include new translations.
š¤ Contributing
We welcome contributions to this template! Open an issue or submit a pull request to suggest improvements.
Check out form-example.tsx to see how its made
Check out sentry-example.tsx to see how its made
Check out toast-example.tsx to see how its made
Check out api-example.tsx to see how its made