A production-ready, full-stack authentication boilerplate built with Next.js 15, Nhost.io, and shadcn/ui. This template provides a complete authentication system with email verification, protected routes, and a modern design system.
- Email/Password Authentication with Nhost
- Email Verification Flow with resend functionality
- Smart Routing based on authentication and verification status
- Persistent Auth State across page refreshes
- Automatic Redirects for protected routes
- shadcn/ui Design System - Professional, accessible components
- Clean, Modern Interface - No gradients, authentic shadcn styling
- Lucide React Icons - Consistent iconography throughout
- Responsive Design that works on all devices
- Dark Mode Support with system preference detection
- Smooth Animations and loading states
- Accessible Components with proper ARIA labels
- Protected Routes with authentication guards
- Email Verification Required for dashboard access
- Secure Environment Variables handling
- TypeScript for type safety
- Error Handling with user-friendly messages
- Next.js 15 with App Router
- shadcn/ui - Modern component library
- Tailwind CSS for styling
- TypeScript for type safety
- Lucide React for icons
- ESLint & Prettier configured
- Hot Reload development server
- Comprehensive Documentation
- Coming Soon
- Node.js 18+
- npm or yarn
- Nhost account (Sign up free)
git clone https://github.com/your-username/nhost-next-template.git
cd nhost-next-template/nhost-next
npm install-
Create Nhost Project:
- Go to Nhost Dashboard
- Click "Create New Project"
- Choose your region and project name
-
Get Project Credentials:
- Copy your Subdomain and Region from the dashboard
-
Configure Environment:
cp .env.example .env.local
Update
.env.local:NEXT_PUBLIC_NHOST_SUBDOMAIN=your-project-subdomain NEXT_PUBLIC_NHOST_REGION=your-project-region
For the movies demo data, run this SQL in your Nhost SQL Editor:
CREATE TABLE movies (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
director VARCHAR(255),
release_year INTEGER,
genre VARCHAR(100),
rating FLOAT
);
INSERT INTO movies (title, director, release_year, genre, rating) VALUES
('Inception', 'Christopher Nolan', 2010, 'Sci-Fi', 8.8),
('The Godfather', 'Francis Ford Coppola', 1972, 'Crime', 9.2),
('Forrest Gump', 'Robert Zemeckis', 1994, 'Drama', 8.8),
('The Matrix', 'Lana Wachowski, Lilly Wachowski', 1999, 'Action', 8.7);Important: Enable "Track this" and set permissions for the public role.
npm run devOpen http://localhost:3000 to see your app! π
-
Landing Page (
/)- Shows different content for authenticated/unauthenticated users
- Beautiful feature showcase
- Call-to-action buttons
-
Authentication (
/auth)- Sign Up: Creates account + sends verification email
- Sign In: Logs in existing users
- Smart Redirects: Based on verification status
-
Email Verification (
/auth/verify-email)- Required for new users
- Resend Email functionality
- Clear Instructions and status updates
-
Dashboard (
/dashboard)- Protected Route - requires verified email
- User Information display
- Sample Data from GraphQL API
- Sign Out functionality
// AuthWrapper handles all routing logic
if (!authenticated) {
redirect('/auth') // Public pages only
}
if (authenticated && !emailVerified) {
redirect('/auth/verify-email') // Must verify email
}
if (authenticated && emailVerified) {
redirect('/dashboard') // Full access
}src/
βββ app/
β βββ auth/
β β βββ page.tsx # π Login/Signup page (shadcn forms)
β β βββ verify-email/
β β βββ page.tsx # βοΈ Email verification (shadcn cards)
β βββ dashboard/
β β βββ page.tsx # π Modern dashboard with stats
β βββ components/
β β βββ AuthWrapper.tsx # π‘οΈ Route protection
β β βββ Providers.tsx # π§ Context providers
β β βββ ui/ # π¨ shadcn/ui components
β β βββ button.tsx
β β βββ card.tsx
β β βββ input.tsx
β β βββ label.tsx
β β βββ alert.tsx
β β βββ badge.tsx
β β βββ avatar.tsx
β β βββ separator.tsx
β βββ layout.tsx # π¨ Root layout
β βββ page.tsx # π Landing page (clean design)
βββ lib/
β βββ nhost.ts # βοΈ Nhost client config
β βββ utils.ts # π§ shadcn/ui utilities
βββ ...
- Clean Hero Section - No gradients, modern typography
- Feature Cards - shadcn Card components with icons
- Tech Stack Badges - shadcn Badge components
- CTA Buttons - shadcn Button with variants
- Responsive Grid Layout - Mobile-first design
- shadcn Card Layout - Professional form container
- shadcn Input & Label - Accessible form controls
- Toggle Sign Up/Sign In - Smooth state management
- shadcn Alert Components - Error/success messages
- Loading States - Lucide Loader2 icons
- Black Background - Modern, high-contrast design
- shadcn Card Structure - Clean, organized layout
- Lucide Icons - Mail, ArrowLeft, Loader2
- shadcn Alert System - Status feedback
- shadcn Buttons - Consistent interaction patterns
- Professional Typography - Clear hierarchy
- Stats Overview Cards - Key metrics at a glance
- User Profile Section - Organized with Lucide icons
- Modern Movie Cards - Replaced table with card layout
- Star Ratings - Visual rating system
- Status Badges - Color-coded verification status
- Avatar Component - User profile representation
| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_NHOST_SUBDOMAIN |
Your Nhost project subdomain | β Yes |
NEXT_PUBLIC_NHOST_REGION |
Your Nhost project region | β Yes |
// src/lib/nhost.ts
export const nhost = new NhostClient({
subdomain: process.env.NEXT_PUBLIC_NHOST_SUBDOMAIN,
region: process.env.NEXT_PUBLIC_NHOST_REGION,
})-
Push to GitHub:
git add . git commit -m "Initial commit" git push origin main
-
Deploy on Vercel:
- Connect your GitHub repository
- Add environment variables in Vercel dashboard
- Deploy automatically
-
Environment Variables:
NEXT_PUBLIC_NHOST_SUBDOMAIN=your-subdomain NEXT_PUBLIC_NHOST_REGION=your-region
- Netlify: Works out of the box
- Railway: Add environment variables
- Render: Configure build settings
- AWS Amplify: Set environment variables
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint- Hot Reload: Changes reflect instantly
- TypeScript: Full type checking
- Console Logs: Check browser console for debugging
- Network Tab: Monitor GraphQL requests
β "createContext only works in Client Components"
- β
Fixed: Using
Providers.tsxwrapper with'use client'
β Authentication not working
- β Check environment variables are set correctly
- β Verify Nhost project is active
- β Check browser console for errors
β Email verification not received
- β Check spam folder
- β Use resend functionality
- β Verify email settings in Nhost dashboard
- Nhost Documentation - Learn about Nhost features
- Next.js Documentation - Next.js guides and API
- Tailwind CSS - Styling documentation
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
Built with β€οΈ using Nhost + Next.js
Happy coding! π