Metronic NextJS
Getting Started

Installation

Get started with Metronic Next.js by following this installation guide.

This guide will help you set up Metronic Next.js for development.

Requirements

Before installing Metronic Next.js, ensure you have:

  • Node.js: Version 18.x or higher
  • npm: Version 9.x or higher (comes with Node.js)
  • Git: Latest version
  • Supabase Account: Required for authentication and database functionality

Installation Steps

Clone the Repository

git clone <repository-url>
cd metronic-nextjs

Install Dependencies

Install project dependencies using npm:

npm install

Note: This project requires React 19 and other modern dependencies.

Environment Setup

  1. Create a .env file in the root directory:
cp .env.example .env
  1. Configure the required environment variables:
# Prisma Config #
# Connect to Supabase via connection pooling.
DATABASE_URL="postgresql://postgres.your-project:your-password@aws-0-region.pooler.supabase.com:6543/postgres?pgbouncer=true"
 
# Direct connection to the database. Used for migrations.
DIRECT_URL="postgresql://postgres.your-project:your-password@aws-0-region.pooler.supabase.com:5432/postgres"
 
# Next Auth Config #
NEXT_PUBLIC_API_URL=http://localhost:3000/api
NEXTAUTH_URL=http://localhost:3000/
NEXTAUTH_SECRET=your-nextauth-secret-key
GOOGLE_CLIENT_ID=your_google_oauth2_client_id
GOOGLE_CLIENT_SECRET=your_google_oauth2_secret_key
 
# Storage Configuration (AWS S3 or DigitalOcean Spaces)
STORAGE_TYPE=digitalocean
 
STORAGE_ACCESS_KEY_ID=your_accent_key_id
STORAGE_SECRET_ACCESS_KEY=your_access_key
STORAGE_REGION=your_region
STORAGE_BUCKET=your_bucket_name
STORAGE_ENDPOINT=your_endpoint
STORAGE_FORCE_PATH_STYLE=true
STORAGE_CDN_URL=your_cdn_url
 
# SMTP Credentials
SMTP_HOST=your_smtp_host
SMTP_PORT=your_smtp_port
SMTP_SECURE=false
SMTP_USER=no-reply@domain.com
SMTP_PASS=your_smtp_pass

Database Setup

This project uses Prisma ORM to interact with the database. Set up your database with:

# Generate Prisma client
npx prisma generate
 
# Run migrations (if needed)
npx prisma migrate dev

Start the Development Server

Run the development server:

npm run dev

The application will be available at:

http://localhost:3000

Build for Production

When you're ready to deploy, build the application:

npm run build

The built files will be in the .next directory and can be deployed to any Next.js compatible hosting service.

Project Structure

The Metronic Next.js project follows a well-organized structure based on the App Router:

app/                    # Next.js App Router directory
├── (auth)/             # Authentication routes (signin, signup, etc.)
├── (protected)/        # Protected routes requiring authentication
│   ├── account/        # Account settings pages
│   ├── page.tsx        # Dashboard page (default protected route)
│   └── layout.tsx      # Layout for protected routes
├── api/                # API routes
│   ├── auth/           # Authentication API endpoints
│   └── [...]/          # Other API endpoints
├── components/         # Shared UI components
│   ├── layouts/        # Multiple demo layouts (Demo1-Demo10)
│   └── ui/             # Base UI components
├── models/             # Data models and interfaces
└── layout.tsx          # Root layout component

components/             # Global UI components
config/                 # Configuration files
css/                    # Global CSS styles
hooks/                  # Custom React hooks
i18n/                   # Internationalization files
lib/                    # Utility libraries
prisma/                 # Prisma schema and migrations
providers/              # React context providers
├── auth-provider.tsx   # Authentication provider
├── i18n-provider.tsx   # Internationalization provider
├── query-provider.tsx  # TanStack Query provider
├── settings-provider.tsx # App settings provider
├── theme-provider.tsx  # Dark/light theme provider
└── tooltips-provider.tsx # Tooltips provider
public/                 # Static assets (images, fonts, etc.)
services/               # API service functions
types/                  # TypeScript type definitions

Next Steps

After installation, you might want to:

Troubleshooting

Common Issues

  1. Port Already in Use

If port 3000 is already in use, Next.js will automatically try to use the next available port. Check your terminal for the correct URL.

  1. Missing Dependencies

If you encounter errors about missing dependencies, try:

npm install
  1. Database Connection Issues

If you're having trouble connecting to your Supabase database, verify your DATABASE_URL and DIRECT_URL in the .env file. Make sure your Supabase project has the right permissions set.

  1. Authentication Problems

For authentication issues, check that your NEXTAUTH_SECRET and OAuth provider credentials are correctly set in the .env file.

  1. Build Errors

If you encounter build errors, ensure you're using the correct Node.js version (18+) and try clearing the node_modules directory:

rm -rf node_modules .next
npm install

For additional help, refer to the Next.js documentation or open an issue on our GitHub repository.