A modern, feature-rich starter kit for Next.js projects with TypeScript, TailwindCSS, multi-language support, and a fully functional contact form. The template can save you hours of setup time and focus on building your unique landing page or application. The template has 100% lighthouse metrics performance.
- Features
- What's Included
- Getting Started
- Project Structure
- Customization
- Theme Configuration Guide
- Environment Variables
- Email Integration
- Google Analytics
- Deployment
- License
- Next.js 15 with App Router for modern React applications
- TypeScript for type safety and improved developer experience
- TailwindCSS v4 for utility-first styling and responsive design
- Multi-language support with English and Arabic (LTR and RTL layouts) with
next-intl
- Contact form with Zod validation and Resend email integration
- Popup Toasts/Notifications using Sonner for user feedback
- Google Analytics integration for tracking user behavior
- Responsive design that works on all devices
- ESLint and Prettier for code quality and consistency
- Clean Landing Page: Simple, modern design that's easy to customize
- Contact Form: Ready-to-use form with validation and email integration
- Language Switcher: Toggle between English and Arabic with automatic RTL support
- SEO Ready: Optimized metadata structure for better search engine visibility
- Performance Optimized: Fast loading times and optimized assets
- Node.js (version 18.x or later recommended)
- pnpm
-
Clone the repository:
git clone https://github.com/maryamaljanabi/nextjs-tailwind-i18n-template my-project
-
Navigate to the project directory:
cd my-project
-
Install dependencies:
pnpm install
-
Set up environment variables:
cp .env.example .env
Then edit
.env
to add your Resend API key and Google Analytics ID.
To start the development server, run:
pnpm dev
Open http://localhost:3000 with your browser to see the result.
βββ public/ # Static assets
βββ src/
β βββ app/ # Next.js app directory (routes, pages)
β β βββ api/ # API routes (send-email)
β β βββ contact/ # Contact page
β β βββ globals.css # Global CSS styles
β β βββ layout.tsx # Root layout for the application
β β βββ page.tsx # Main page component
β βββ components/ # Reusable UI components
β β βββ contact/ # Contact form related components
β β βββ layout/ # Layout components (e.g., Navbar, Footer)
β β βββ shared/ # Shared components (e.g., LanguageSwitcher)
β β βββ ui/ # Shadcn/ui components
β βββ i18n/ # Internationalization (next-intl) configuration and translations
β β βββ request.ts # Request configuration for next-intl
β β βββ routing.ts # Routing configuration for next-intl
β β βββ translations/ # Translation files
β β βββ ar.json # Arabic translations
β β βββ en.json # English translations
β β βββ utils.ts # Utility functions for i18n
β β βββ actions.ts # Server actions for i18n
β βββ lib/ # Utility functions and libraries
β β βββ emails/ # Email templates
β β βββ metadata.ts # Metadata utilities
β β βββ utils.ts # General utility functions
This template uses TailwindCSS for styling. You can customize the theme in globals.css
.
Create new directories in the src/app
directory to add new pages to your application.
Add or modify translations in the src/i18n/translations
directory. The template supports English (en.json
) and Arabic (ar.json
) by default.
To add a new language:
- Create a new JSON file in the
src/i18n/translations
directory (e.g.,fr.json
) - Update the
language-context.tsx
file to include the new language. - Add the language to the
Language
type and constant insrc/i18n/utils.ts
. This will be reflected in thenext-intl
config specified in thesrc/i18n/routing.ts
The template decouples RTL support from specific languages, allowing you to associate RTL with any language you need. To configure RTL support:
- In
src/i18n/utils.ts
, modify theRTL_LANGUAGES
array to include any languages that should use RTL layout:
// Define which languages use RTL direction
const RTL_LANGUAGES = ["ar", "fa"]; // Example: Arabic, Persian
- The language context will automatically apply RTL styling when a language in this array is selected.
The language switcher component in the navbar allows users to toggle between available languages. It features:
- A globe icon for universal recognition
- Responsive design that works on all screen sizes
- Automatic RTL/LTR switching based on the selected language
This guide explains how to add and configure custom theme colors and values in a Tailwind CSS v4 + shadcn/ui project.
Follow these steps in order to add a new color to your theme:
In your globals.css, add the new color to the :root
block, for example, to add a new color variable named brand
:
:root {
/* Existing colors... */
/* Add your new colors */
--brand: oklch(0.6 0.2 240);
}
Add the corresponding mapping in the @theme inline
block:
@theme inline {
/* Existing mappings... */
/* Add your new color mappings */
--color-brand: var(--brand);
}
Now you can use your new color with Tailwind utilities:
// Background colors
<div className="bg-brand">Brand section</div>
// Text colors
<p className="text-brand">Brand colored text</p>
// Borders
<div className="border-brand">Brand border</div>
// Hover states
<button className="bg-brand hover:bg-brand/90">Brand button</button>
You can also add other design tokens like spacing, or border radius:
/* Step 1: In :root */
:root {
--spacing-section: 5rem;
--spacing-component: 2rem;
}
/* Step 2: In @theme inline */
@theme inline {
--spacing-section: var(--spacing-section);
--spacing-component: var(--spacing-component);
}
Adding custom fonts involves a few steps to ensure they are correctly integrated and applied throughout the application:
First, import your required font in the main layout file. For example, to import 'Open Sans':
import { Open_Sans } from 'next/font/google';
const openSans = Open_Sans({
variable: '--font-open-sans',
subsets: ['latin'],
display: "swap",
});
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={`${openSans.variable}`}>
<body>{children}</body>
</html>
);
}
You can apply the font directly using Tailwind classes:
<p className="font-(family-name:--font-open-sans)">This text uses Open Sans.</p>
Or, to apply it globally to the body
tag, you can add it to globals.css
:
body {
font-family: var(--font-open-sans);
}
This project uses environment variables to manage sensitive information and configuration. Before running the application, ensure you have set up the following variables in your .env
file:
RESEND_API_KEY
: Your API key for Resend, used for sending emails via the contact form.GOOGLE_ANALYTICS_ID
: Your Google Analytics Measurement ID (e.g.,G-XXXXXXXXXX
) for tracking user behavior.EMAIL_FROM
: The email address from which the contact form submissions will appear to be sent (e.g.,onboarding@resend.dev
). This should be a verified sender in your Resend account.EMAIL_TO
: The email address to which contact form submissions will be sent (e.g.,your-email@example.com
).
To set up your environment variables, copy the example file and then edit it with your actual values:
cp .env.example .env
This template uses Resend for sending emails from the contact form. To set it up:
- Sign up for a Resend account
- Get your API key
- Add it to your
.env
file asRESEND_API_KEY
- The resend implementation is in
src/app/api/send-email/route.ts
. The 'from' and 'to' email addresses for the contact form are configured via environment variables (EMAIL_FROM
andEMAIL_TO
) for flexibility and security. Ensure these are properly set in your.env
file as described in the Environment Variables section.
Make sure the email used in the from
field is from a domain you have verified with Resend. The to
field should be the email address where you want to receive the contact form submissions.
To enable Google Analytics:
- Create a Google Analytics 4 property and get your Measurement ID
- Add it to your
.env
file asNEXT_PUBLIC_GA_ID
This project can be easily deployed on platforms like Vercel, Netlify, or any other hosting provider that supports Next.js applications. Do not forget to set your environment variables for production in any hosting service.
- @next/third-parties: For integrating third-party scripts like Google Analytics
- resend: For sending emails from the contact form
- sonner: For beautiful toast notifications
- zod: For form validation and type safety
- tailwind-merge & class-variance-authority: For managing Tailwind classes
- lucide-react: For icons
- prettier & eslint: For code formatting and linting
- next-intl: For smooth i18n experience
- MIT License
- Copyright 2025 Β© Maryam Aljanabi