Skip to content

A modern, production-ready Next.js starter template with internationalization (i18n) support, built with the latest technologies and best practices.

License

Notifications You must be signed in to change notification settings

alanbasilio/next-polyglot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 Next Polyglot

A modern, production-ready Next.js starter template with internationalization (i18n) support, built with the latest technologies and best practices.

πŸš€ Features

🌐 Core Features

  • Internationalization: Multi-language support with i18next
  • Next.js 15: Latest version with App Router and Turbopack
  • TypeScript: Full type safety with strict mode
  • Tailwind CSS 4: Modern utility-first CSS framework
  • Radix UI: Accessible and customizable UI components
  • TanStack Query: Powerful data synchronization

πŸ”§ Developer Experience

  • Prettier: Automatic code formatting with import sorting
  • ESLint: Custom rules with Prettier integration
  • Husky: Git hooks for pre-commit, commit-msg, and pre-push
  • Lint-staged: Automatic formatting on commit
  • Commitlint: Conventional commits enforcement
  • Bundle Analyzer: Performance analysis (yarn analyze)
  • VSCode: Optimized settings and extensions
  • TypeScript: Strict mode and advanced configurations

🎨 UI/UX

  • Dark/Light Mode: Seamless theme switching with next-themes
  • Theme System: Comprehensive theme provider and switcher
  • Responsive Design: Mobile-first approach
  • Accessible Components: WCAG compliant with Radix UI
  • Modern Design: Clean and professional interface

πŸ”’ Security

  • Security Headers: CSP, HSTS, X-Frame-Options, and more
  • Content Security Policy: Configured for maximum security
  • Type-safe Environment Variables: Zod validation
  • Input Validation: Schema-based validation system

πŸ” SEO & Performance

  • Dynamic Metadata: Optimized meta tags and OpenGraph
  • Twitter Cards: Social media optimization
  • JSON-LD: Structured data for better search results
  • Image Optimization: AVIF/WebP support
  • Bundle Optimization: Automatic code splitting and optimization

🌐 Internationalization

  • i18next: Complete i18n framework
  • Language Detection: Automatic browser language detection
  • Middleware: Smart routing for language-specific pages
  • Type-safe Translations: Full TypeScript support

πŸ“¦ DevOps & Deployment

  • Automated Dependencies: Renovate/Dependabot integration
  • GitHub Actions: CI/CD pipeline ready
  • Vercel Optimized: One-click deployment
  • Docker Ready: Containerization support

πŸ› οΈ Tech Stack

Core

Internationalization

UI & Styling

Data Fetching

Development Tools

Validation & Security

  • Zod - Schema validation
  • Security Headers - Comprehensive security configuration

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • Yarn (recommended)

Installation

# Clone the repository
git clone <repository-url>
cd next-polyglot

# Install dependencies
yarn install

# Start development server
yarn dev

Open http://localhost:3000 with your browser to see the result.

πŸ“ Project Structure

next-polyglot/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ [lng]/                 # Language-specific pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Layout with theme support
β”‚   β”‚   └── page.tsx           # Home page
β”‚   β”œβ”€β”€ components/            # Shared components
β”‚   β”‚   β”œβ”€β”€ ui/                # UI components
β”‚   β”‚   β”œβ”€β”€ theme-provider.tsx # Theme context
β”‚   β”‚   β”œβ”€β”€ theme-switcher.tsx # Theme toggle
β”‚   β”‚   └── language-switcher.tsx
β”‚   └── globals.css            # Global styles
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ i18n/                  # i18n configuration
β”‚   β”œβ”€β”€ react-query/           # React Query setup
β”‚   β”œβ”€β”€ metadata.ts            # SEO utilities
β”‚   β”œβ”€β”€ env.ts                 # Environment validation
β”‚   └── utils.ts               # Utility functions
β”œβ”€β”€ public/
β”‚   └── locales/               # Translation files
β”‚       β”œβ”€β”€ en/
β”‚       └── pt/
β”œβ”€β”€ .husky/                    # Git hooks
β”œβ”€β”€ .vscode/                   # VSCode configuration
β”œβ”€β”€ middleware.ts              # Next.js middleware
β”œβ”€β”€ next.config.ts             # Next.js configuration
β”œβ”€β”€ commitlint.config.js       # Commitlint configuration
β”œβ”€β”€ .prettierrc.json           # Prettier configuration
└── components.json            # shadcn/ui configuration

🌍 Internationalization

Supported Languages

  • English (en)
  • Portuguese (pt)

Adding New Languages

  1. Add the language code to lib/i18n/settings.ts:
export const languages = ['en', 'pt', 'es']; // Add 'es' for Spanish
  1. Create translation files in public/locales/[lang]/:
public/locales/es/common.json
  1. Add translations to the new file:
{
  "welcome": "Bienvenido",
  "edit": "Editar"
  // ... more translations
}

Using Translations

import { useTranslation } from 'react-i18next';

export default function Component() {
  const { t } = useTranslation('en');

  return <h1>{t('welcome')}</h1>;
}

🎨 Themes

Theme System

This starter includes a comprehensive theme system with:

  • Light/Dark modes with system preference detection
  • Theme Provider for consistent theming
  • Theme Switcher component with smooth transitions
  • Tailwind CSS integration with CSS variables

Using Themes

import { useTheme } from 'next-themes';

export default function Component() {
  const { theme, setTheme } = useTheme();

  return (
    <button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
      Toggle theme
    </button>
  );
}

πŸ“¦ Scripts

Development

yarn dev              # Start development server with Turbopack
yarn build            # Build for production
yarn start            # Start production server
yarn lint             # Run ESLint
yarn lint:fix         # Fix linting issues automatically
yarn format           # Format code with Prettier
yarn format:check     # Check code formatting
yarn type-check       # TypeScript type checking
yarn analyze          # Analyze bundle size

Dependencies

yarn deps:check       # Check for outdated packages
yarn deps:update      # Update dependencies interactively
yarn deps:audit       # Security audit
yarn deps:fix         # Fix vulnerabilities

πŸ”’ Security

Security Headers

This starter includes comprehensive security headers:

  • Content Security Policy (CSP)
  • HTTP Strict Transport Security (HSTS)
  • X-Frame-Options
  • X-Content-Type-Options
  • Referrer-Policy
  • Permissions-Policy

Environment Variables

Type-safe environment variables with Zod validation:

// lib/env.ts
import { z } from 'zod';

const envSchema = z.object({
  NODE_ENV: z.enum(['development', 'production', 'test']),
  NEXT_PUBLIC_APP_URL: z.string().url(),
});

export const env = envSchema.parse(process.env);

πŸ” SEO Optimization

Metadata API

Dynamic metadata generation with:

  • OpenGraph tags
  • Twitter Cards
  • JSON-LD structured data
  • Language alternates
  • Canonical URLs

Usage

import { generateMetadata } from '@/lib/metadata';

export const metadata = generateMetadata({
  title: 'Your Page Title',
  description: 'Your page description',
  image: '/og-image.jpg',
});

🎯 Git Hooks & Code Quality

Automated Checks

  • Pre-commit: Linting and formatting
  • Commit-msg: Conventional commits validation
  • Pre-push: Type checking and tests

Conventional Commits

This project uses conventional commits:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation
  • style: Code style/formatting
  • refactor: Code refactoring
  • test: Tests
  • chore: Maintenance tasks

πŸš€ Deployment

Vercel (Recommended)

The easiest way to deploy your Next.js app is to use the Vercel Platform.

# Deploy to Vercel
vercel --prod

Other Platforms

This Next.js app can be deployed to any platform that supports Node.js:

  • Netlify
  • Railway
  • DigitalOcean
  • AWS
  • Google Cloud

πŸ“Š Performance

Bundle Analysis

Analyze your bundle size:

yarn analyze

Optimization Features

  • Automatic code splitting
  • Image optimization (AVIF/WebP)
  • Font optimization
  • CSS optimization
  • JavaScript minification

πŸ§ͺ Testing (Coming Soon)

Planned Testing Setup

  • Jest + React Testing Library for unit tests
  • Playwright for E2E tests
  • Storybook for component documentation
  • Coverage reporting

πŸ“ˆ Monitoring (Coming Soon)

Planned Monitoring Tools

  • Sentry for error tracking
  • Web Vitals tracking
  • Performance monitoring
  • Real User Monitoring (RUM)

🀝 Contributing

How to Contribute

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using conventional commits
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/alanbasilio/next-polyglot.git
cd next-polyglot

# Install dependencies
yarn install

# Set up git hooks
yarn prepare

# Start development
yarn dev

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links


Happy coding! πŸŽ‰

About

A modern, production-ready Next.js starter template with internationalization (i18n) support, built with the latest technologies and best practices.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •