Next.js Boilerplate by ixartz

repository·main·Indexed 12 days ago

https://github.com/ixartz/next-js-boilerplate

A high-performance starter kit for modern web applications using Next.js 16+ (App Router), Tailwind CSS 4, and TypeScript. It integrates a comprehensive stack including Clerk for authentication, DrizzleORM with PGlite and Neon, Arcjet for security, Sentry for error monitoring, and a testing suite featuring Vitest and Playwright.

Tokens
9.1K
Snippets
40
Records
46
Agent score
95%

What's inside Next.js Boilerplate

  1. Overview of the Next.js Boilerplate stack

    main

    This project is a comprehensive boilerplate and starter kit designed for Next.js 16+ using the App Router, Tailwind CSS 4, and TypeScript. It prioritizes developer experience by integrating a wide range of modern tools for testing, linting, authentication, database management, and security.

    Key technologies included:

    • Framework: Next.js 16+ (App Router)
    • Styling: Tailwind CSS 4
    • Language: TypeScript
    • Authentication: Clerk
    • ORM: DrizzleORM (supports PostgreSQL, SQLite, and MySQL)
    • Databases: PGlite (local) and Neon (production)
    • Testing: Vitest, Testing Library, and Playwright
    • Security: Arcjet (Bot detection, Rate limiting, Attack protection)
    • Error Monitoring: Sentry
    • Logging: LogTape
    • Git Hooks: Lefthook and Lint-Staged
    • UI/Documentation: Storybook
  2. Set up i18n with Crowdin

    main

    The project uses next-intl and Crowdin for translations.

    To automate translations:

    1. Create a project on Crowdin.com and retrieve your Project ID.
    2. Create a Personal Access Token in Crowdin (Account Settings > API).
    3. Define CROWDIN_PROJECT_ID and CROWDIN_PERSONAL_TOKEN as environment variables in your GitHub Actions.

    Localization files will synchronize with Crowdin on every push to the main branch.

  3. Use Conventional Commits

    main

    The project follows the Conventional Commits specification. Use the interactive CLI to guide your commit process.

    Command: npm run commit

    Common Types:

    • feat: New feature
    • fix: Bug fix
    • docs: Documentation
    • style: Code formatting
    • refactor: Code restructuring
    • test: Adding/updating tests
    • chore: Maintenance tasks
    npm run commit
  4. Set up a remote PostgreSQL database

    main

    While the project uses PGlite for local development, you should use a remote PostgreSQL provider (like Neon) for production.

    To set up a remote database:

    1. Create a PostgreSQL database and obtain the connection string.
    2. Add the connection string to the DATABASE_URL variable in your .env.production file.
  5. Modify the database schema with Drizzle ORM

    main

    The database structure is defined in ./src/models/Schema.ts. To apply changes:

    1. Update the schema file.
    2. Generate a migration: npm run db:generate.
    3. Apply the migration: npm run db:migrate.
    npm run db:generate
    npm run db:migrate
  6. Build and deploy to production

    main

    Local Production Build

    To test an optimized build locally using an in-memory database: npm run build-local

    Production Deployment

    1. Ensure DATABASE_URL and CLERK_SECRET_KEY are defined in your environment.
    2. Generate the build: npm run build.
    3. Start the server: npm run start.
    npm run build-local
    npm run build
    npm run start
  7. Get started with Next.js Boilerplate

    main

    To set up the project locally, clone the repository, install dependencies, and run the development server. The project is pre-configured with a local database using PGlite, so no additional database setup is required for local development.

    Requirements:

    • Node.js 24+
    • npm
    git clone --depth=1 https://github.com/ixartz/Next-js-Boilerplate.git my-project-name
    cd my-project-name
    npm install
    npm run dev
  8. Run unit and integration tests

    main

    The project uses Vitest for unit testing and Playwright for E2E/Integration testing.

    Unit Tests: Run npm run test to execute tests located in *.test.ts or *.test.tsx files.

    E2E/Integration Tests: Files use *.integ.ts or *.e2e.ts extensions.

    1. Install Playwright (first time only): npx playwright install
    2. Run tests: npm run test:e2e
    npx playwright install
    npm run test:e2e