Pozdravljeni in dobrodoΕ‘li v NextJS predlogi

To je predloga za NextJS s TailwindCSS, TypeScript, i18n, Jest, Zod, React Hook Form, shadcn/ui in več!

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:

  1. 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
    
  2. Navigate into your new project folder:

    cd your-project-name
    
  3. Install dependencies:

    pnpm i
    
  4. 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-query for API calls
    • Supports mocking and integration with Biome.js
  • 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')
  • 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.

βœ… Form example

Check out form-example.tsx to see how its made

πŸš€ Sentry example

Check out sentry-example.tsx to see how its made

πŸ”” Toast example

Check out toast-example.tsx to see how its made

πŸ“ž API call example

Check out api-example.tsx to see how its made