A production-ready template for building applications with the IGRP Framework on Next.js 15. This template provides a complete foundation with authentication, layout management, and a modern UI built on top of the IGRP design system.
- Overview
- Prerequisites
- Getting Started
- Project Structure
- Configuration
- Environment Variables
- Available Scripts
- How It's Built
- Authentication
- Preview Mode
- Docker Support
The IGRP Framework Next.js Template is a comprehensive starter template that includes:
- Next.js 15 with App Router and Turbopack
- IGRP Framework integration with layout management
- NextAuth.js for authentication
- TypeScript for type safety
- Tailwind CSS for styling
- React Query for data fetching
- React Hook Form with Zod validation
- Biome for code formatting and linting
- Lucide for icon library
- Modern UI Components from IGRP Design System
Before you begin, ensure you have the following installed:
- Node.js >= 22.x.x
- pnpm (recommended) or npm/yarn
- Git
pnpm installCreate a .env.local file in the root directory with the following variables:
# Application Configuration
IGRP_APP_CODE=your-app-code
IGRP_PREVIEW_MODE=false
NEXT_PUBLIC_BASE_PATH=
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_URL_INTERNAL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here
# API Configuration
IGRP_ACCESS_MANAGEMENT_API=https://your-api-url.com
NEXT_PUBLIC_IGRP_APP_HOME_SLUG=/
NEXT_IGRP_APP_CENTER_URL=https://app-center-url.com
# Image Domains (comma-separated)
NEXT_PUBLIC_ALLOWED_DOMAINS=example.com,cdn.example.compnpm devOpen http://localhost:3000 in your browser to see the application.
pnpm build
pnpm starttemplates/demo/
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ (auth)/ # Authentication routes (login, logout)
β β βββ (igrp)/ # IGRP-protected routes
β β β βββ layout.tsx # IGRP layout wrapper
β β β βββ page.tsx # Home page
β β βββ api/ # API routes
β β β βββ auth/ # NextAuth API routes
β β βββ layout.tsx # Root layout
β βββ actions/ # Server actions
β β βββ igrp/ # IGRP-specific actions
β βββ config/ # Configuration files
β β βββ login.ts # Login configuration
β β βββ site.ts # Site metadata
β βββ lib/ # Utility libraries
β β βββ auth-helpers.ts # Authentication helpers
β β βββ auth-options.ts # NextAuth configuration
β β βββ fonts.ts # Font configuration
β βββ temp/ # Mock data (for preview mode)
β β βββ applications/ # Mock applications
β β βββ menus/ # Mock menu items
β β βββ users/ # Mock user data
β βββ styles/ # Global styles
β βββ middleware.ts # Next.js middleware
β βββ igrp.template.config.ts # IGRP configuration builder
βββ public/ # Static assets
βββ create-template/ # Template publishing scripts
βββ docker/ # Docker configuration
βββ package.json
The main IGRP configuration is built in src/igrp.template.config.ts. This file:
- Configures the IGRP layout (header, sidebar, menus)
- Sets up authentication and session management
- Defines preview mode behavior
- Configures API management client
The layout is configured in src/app/(igrp)/layout.tsx:
- Wraps routes with IGRP layout components
- Handles authentication redirects
- Manages session state
- Configures preview mode
Coming soon
Coming soon
| Variable | Description | Example |
|---|---|---|
IGRP_APP_CODE |
Your application code identifier | my-app |
NEXTAUTH_URL |
Public URL of your application | http://localhost:3000 |
NEXTAUTH_SECRET |
Secret key for NextAuth encryption | Generate with openssl rand -base64 32 |
| Variable | Description | Default |
|---|---|---|
IGRP_PREVIEW_MODE |
Enable preview mode (no auth required) | false |
IGRP_ACCESS_MANAGEMENT_API |
API Management base URL | - |
NEXT_PUBLIC_BASE_PATH |
Base path for the application | / |
NEXT_PUBLIC_IGRP_APP_HOME_SLUG |
Default home route | / |
NEXT_IGRP_APP_CENTER_URL |
Application center URL | - |
NEXT_PUBLIC_ALLOWED_DOMAINS |
Allowed image domains (comma-separated) | - |
IGRP_SYNC_ON_CODE_MENUS |
Enable synchronization of menus defined in code with the IGRP system | false |
IGRP_SYNC_ACCESS |
Enable synchronization of applications, resources, and menus with the IGRP Access Management API | true |
IGRP_M2M_SERVICE_ID |
Unique identifier for your service in the IGRP Access Management system (required when IGRP_SYNC_ACCESS=true) |
- |
IGRP_M2M_TOKEN |
Authentication token for machine-to-machine API calls (required when IGRP_SYNC_ACCESS=true) |
- |
The following variables control how your application synchronizes with the IGRP system:
- Purpose: Controls whether menus defined in your application code are synchronized with the IGRP system
- Usage: Set to
trueto enable code-based menu synchronization,falseto disable - When to use: Enable this if you want to sync menus that are hardcoded in your application with the IGRP framework
- Purpose: Controls synchronization of applications, resources, and menus with the IGRP Access Management API
- Usage: Set to
trueto enable access management synchronization,falseto disable - When to use: Enable this if you want your application to automatically sync its structure (applications, resources, menus) with the IGRP Access Management system
- Note: Requires
IGRP_M2M_SERVICE_IDandIGRP_M2M_TOKENto be configured when enabled
- Purpose: Unique identifier for your service in the IGRP Access Management system
- Usage: Set this to your service identifier (e.g.,
demo-igrporyour-service-name) - Required when:
IGRP_SYNC_ACCESS=true - How to get: Contact your IGRP Access Management administrator
- Purpose: Authentication token used for machine-to-machine API calls to the IGRP Access Management API
- Usage: Set this to the token provided by your IGRP Access Management administrator
- Required when:
IGRP_SYNC_ACCESS=true - How to get: Contact your IGRP Access Management administrator
- Security: Keep this token secure and never commit it to version control
# Start development server with Turbopack
pnpm dev
# Format code with Biome
pnpm format
# Lint and fix code with Biome
pnpm lint# Build for production (includes formatting)
pnpm build
# Start production server
pnpm startThe template follows Next.js 15 App Router architecture with the following key components:
- Provides global layout structure
- Configures metadata and viewport
- Wraps application with IGRP root layout
- Handles authentication checks
- Manages session state
- Redirects unauthenticated users to login
- Wraps routes with IGRP layout components (header, sidebar)
- Intercepts requests before they reach pages
- Validates authentication tokens
- Handles public paths (login, logout, API routes)
- Supports preview mode bypass
- Builds IGRP configuration object
- Loads mock data for preview mode
- Configures layout, API, and toaster settings
- Manages session configuration
layout.ts: Fetches layout configuration and sessionauth.ts: Authentication-related actions
- Next.js 15: React framework with App Router
- Turbopack: Fast bundler for development
- TypeScript: Type-safe JavaScript
- NextAuth.js: Authentication library
- React Query: Server state management
- React Hook Form: Form handling
- Zod: Schema validation
- Tailwind CSS: Utility-first CSS framework
- Biome: Fast formatter and linter
- Request arrives β Middleware checks authentication
- Authenticated β Request proceeds to layout
- Layout loads β Fetches configuration and session
- Configuration built β IGRP layout components render
- Page renders β With header, sidebar, and content
The template uses NextAuth.js for authentication. Configuration is in src/lib/auth-options.ts.
- User visits protected route
- Middleware checks for valid session
- If no session β Redirect to
/login - User authenticates β Session created
- User redirected to original destination
To customize authentication:
- Edit
src/lib/auth-options.tsto configure providers - Update
src/app/(auth)/login/page.tsxfor custom login UI - Modify
src/middleware.tsfor custom auth logic
Preview mode allows you to develop and test without authentication:
IGRP_PREVIEW_MODE=trueWhen enabled:
- Authentication checks are bypassed
- Mock data is used for menus, users, and applications
- Session refetching is disabled
- No redirects to login page
Mock data sources:
src/temp/users/use-mock-user.tssrc/temp/menus/use-mock-menus.tssrc/temp/applications/use-mock-apps.ts
docker build -f docker/development/Dockerfile -t my-igrp-template:latest .
docker run -d --name my-igrp-template -p 3000:3000 --restart unless-stopped --env-file docker/development/.env.development my-igrp-template:latestUse the production Dockerfile with appropriate environment variables.
- Next.js Documentation
- IGRP Framework Documentation
- NextAuth.js Documentation
- React Query Documentation
Contributions are welcome! Please ensure you:
- Follow the code style (Biome formatting)
- Add appropriate TypeScript types
- Test your changes thoroughly
- Update documentation as needed
MIT License - see LICENSE file for details
Built with β€οΈ by the IGRP Team