next-intl-auth Tailwind Templates

Next Intl Auth

Authentication and i18n boilerplate built with Next.js 14, next-auth, next-intl, Tailwind CSS, and shadcn/ui.

Next Intl Auth Boilerplate

A complete, production-grade Next.js starter with internationalization, authentication, UI components, testing and more. Production-ready Next.js boilerplate for authentication, i18n, theming and testing.



๐Ÿ”ฅ Preview

Deployment

This project is live and deployed on Vercel!
Visit the live demo: Next Intl Auth Boilerplate Live

Features

  • โšก๏ธ Next.js 14: Fast and scalable React framework with App Router.
  • ๐ŸŒ next-intl: Internationalization (i18n) with fully typed translations.
  • ๐Ÿ”’ Next-Auth v5: Authentication with JWT, OAuth, and social providers.
  • ๐ŸŽจ shadcn/ui: Beautiful accessible components with Tailwind CSS.
  • ๐Ÿ›ก๏ธ Zod: End-to-end type-safe validation.
  • ๐Ÿš€ TypeScript: 100% typed full-stack application.
  • ๐ŸŒ“ Dark Mode: Light / dark mode with system preference.
  • ๐Ÿ“ˆ React Query: Powerful data fetching and caching.
  • ๐Ÿงช Vitest & Playwright: Full testing stack (unit, integration, e2e).

Quick Start

Prerequisites

Make sure you have the following installed:

  • Node.js >= 18.x
  • Yarn (preferred) or npm
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/Sayyat/next-intl-auth.git
    cd next-intl-auth
    
  2. Install dependencies:

    yarn install
    
  3. Create a .env file in the root directory and add the following environment variables:

    API_URL=<Your API URL>
    AUTH_SECRET=<Your Auth Secret>
    NEXTAUTH_URL=http://localhost:3000
    API_URL=http://127.0.0.1:8000
    
  4. Start the development server:

    yarn dev
    

    The application will be available at http://localhost:3000.


File Structure

Click to expand the file structure
src/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ (ui)/
โ”‚   โ”‚   โ”œโ”€โ”€ group-1/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ about
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ profile
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ page.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ group-2/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ analytics
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ dashboard
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ page.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ settings
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ auth/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ [...nextauth]/
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ route.ts
โ”‚   โ”‚   โ””โ”€โ”€ proxy/
โ”‚   โ”‚       โ””โ”€โ”€ [...pathname]/
โ”‚   โ”‚           โ””โ”€โ”€ route.ts
โ”‚   โ””โ”€โ”€ layout.tsx
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ AppSidebar.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ DynamicBreadcrumb.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Footer.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Header.test.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Header.tsx
โ”‚   โ”‚   โ””โ”€โ”€ RenderSidebarGroup.tsx
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ routes.ts
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ””โ”€โ”€ useDynamicBreadcrumb.ts
โ”‚   โ”œโ”€โ”€ providers/
โ”‚   โ”‚   โ”‚โ”€โ”€ ClientProvidersWrapper.tsx
โ”‚   โ”‚   โ””โ”€โ”€ ThemeProvider.tsx
โ”‚   โ”œโ”€โ”€ styles/
โ”‚   โ”‚   โ””โ”€โ”€ globals.css
โ”‚   โ””โ”€โ”€ types/
โ”‚       โ”‚โ”€โ”€ header.d.ts
โ”‚       โ””โ”€โ”€ routes.d.ts
โ”œโ”€โ”€ features/
โ”‚   โ”œโ”€โ”€ authentication/
โ”‚   โ”‚   โ”‚โ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ EmailSentDialog.tsx
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ LoginDialog.tsx
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ ProfileDialog.tsx
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ ProfileImageIcon.tsx
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ RegisterDialog.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ResetDialog.tsx
โ”‚   โ”‚   โ”‚โ”€โ”€ hooks/
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ useAuth.ts
โ”‚   โ”‚   โ”‚   โ”‚โ”€โ”€ useCities.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ useProfile.ts
โ”‚   โ”‚   โ””โ”€โ”€ lib/
โ”‚   โ”‚       โ”‚โ”€โ”€ queryKeys.ts
โ”‚   โ”‚       โ””โ”€โ”€ zod.ts
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ client.ts
โ”‚   โ”‚   โ””โ”€โ”€ server.ts
โ”‚   โ”œโ”€โ”€ types/
โ”‚   โ”‚   โ”œโ”€โ”€ city.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ payload.d.ts
โ”‚   โ”‚   โ”œโ”€โ”€ profile.d.ts
โ”‚   โ”‚   โ””โ”€โ”€ response.d.ts
โ”‚   โ””โ”€โ”€ index.ts
โ”œโ”€โ”€ locales/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”œโ”€โ”€ locales.ts
โ”‚   โ”‚   โ”œโ”€โ”€ request.ts
โ”‚   โ”‚   โ”œโ”€โ”€ server.ts
โ”‚   โ”‚   โ”œโ”€โ”€ translation.ts
โ”‚   โ”‚   โ””โ”€โ”€ translation-types.d.ts
โ”‚   โ””โ”€โ”€ messages/
โ”‚       โ”œโ”€โ”€ en.json
โ”‚       โ”œโ”€โ”€ kk.json
โ”‚       โ””โ”€โ”€ ru.json
โ”œโ”€โ”€ shared/
โ”‚   โ””โ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ svg/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Loading.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ ui/ - shadcn ui components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ accordion.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ...............
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ tooltip.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ app-sidebar.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Checkbox.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ FloatingLabelInput.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ FloatingLabelPasswordInput.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ FloatingLabelPhoneInput.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Input.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ LanguageSelect.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ nav-main.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ nav-projects.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ nav-secondary.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ nav-user.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Select.tsx
โ”‚   โ”‚   โ””โ”€โ”€ ThemeSelect.tsx
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ””โ”€โ”€ env/
โ”‚   โ”‚       โ”œโ”€โ”€ client.ts
โ”‚   โ”‚       โ””โ”€โ”€ server.ts
โ”‚   โ”œโ”€โ”€ hooks/ shadcn hooks + custom shared hooks
โ”‚   โ”‚   โ”œโ”€โ”€ use-mobile.ts
โ”‚   โ”‚   โ””โ”€โ”€ use-toast.ts
โ”‚   โ”‚โ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ case.ts
โ”‚   โ”‚   โ”œโ”€โ”€ constants.ts
โ”‚   โ”‚   โ”œโ”€โ”€ query.ts
โ”‚   โ”‚   โ”œโ”€โ”€ tokenService.ts
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts
โ”‚   โ”‚โ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ api.ts
โ”‚   โ”‚   โ”œโ”€โ”€ client.ts
โ”‚   โ”‚   โ””โ”€โ”€ server.ts
โ”‚   โ””โ”€โ”€ types/
โ”‚       โ”œโ”€โ”€ api.d.ts
โ”‚       โ”œโ”€โ”€ next-auth.d.ts
โ”‚       โ””โ”€โ”€ next-intl.d.ts
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ e2e/ - all e2e tests folder
โ”‚   โ””โ”€โ”€ setup.ts
โ”œโ”€โ”€ auth.ts
โ””โ”€โ”€ middleware.ts 

How to Use

Authentication

  • Sign Up: Use the /register page to create a new account. The backend API handles user registration and returns access and refresh tokens.
  • Log In: Access /login to authenticate users. Tokens are stored securely, and JWT is decoded for user details.

Localization

  • The project uses next-intl for localization.
  • Languages supported: Kazakh, English, and Russian.
  • The language can be changed using the dropdown in the header.

Toast Notifications

  • Feedback is provided using react-toastify.
  • Example: Error messages during authentication or form validation feedback.

Zod Validation

  • Zod is used for client-side schema validation for forms.
  • Errors are displayed with translations based on the current locale.

Customization

Add New Languages

  1. Create a new JSON file in the locales/messages/ directory, e.g., fr.json for French.

  2. Add translations for the keys in the JSON file.

  3. Update the locales array in locales/config/locales.ts:

    export const locales = ['en', 'ru', 'kk', 'fr'];
    
  4. The language will automatically be added to the selector.

Add New Pages

  1. Create a new folder under the app directory, e.g., app/dashboard.
  2. Add a new page.tsx file inside the folder.
  3. Use the existing components for layout and styles.

๐Ÿ“š Tech Stack

Technology Description
Next.js React framework with server-side rendering
Next-Auth Authentication system for Next.js apps
Next-Intl Localization and translation management
Tailwind CSS Utility-first CSS framework
shadcn/ui Beautiful prebuilt components
TypeScript Static typing for scalable applications
Zod Type-safe schema validation
@tanstack/react-query Powerful data fetching library
Vitest Fast unit testing framework
Playwright Type-safe environment variable management for Next.js
@t3-oss/env-nextjs End-to-end browser testing framework
React-Toastify Toast notifications

๐Ÿš€ Running Tests

This project includes a robust testing setup to ensure code quality and application reliability. Below are the details for running different types of tests:

1. Unit and Integration Tests

We use Vitest with React Testing Library to write and run unit and integration tests.

Run Unit/Integration Tests:

yarn test

Watch Tests:

yarn test:watch

Coverage Report:

yarn coverage

2. End-to-End (E2E) Tests

We use Playwright for writing end-to-end tests.

Run E2E Tests:

yarn test:e2e

Playwright Test Runner UI:

yarn test:e2e --ui

Notes:

  • Ensure the application is running locally before starting E2E tests.
  • Configure environment variables in .env.test for test-specific setups.

3. Test Setup

Test Directory Structure

  • Unit tests: src/ (next to each component)
  • E2E tests: src/tests/e2e/

Example Test Command:

yarn test  # Runs all unit and integration tests
yarn test:e2e  # Runs all E2E tests

License

This project is licensed under the GNU General Public License v3.0.
See the LICENSE file for details. This project is licensed under the terms of the GNU GPL v3.


Author

Made with ๐Ÿ’œ by Sayat Raykul (ZIZ INC)

If you like this project, please โญ๏ธ star it on GitHub!
It helps me continue building great open-source tools.

Top categories

Loading Svelte Themes