Documentation
Comprehensive guide for the Next Template project.
Documentation
Prerequisites
Before getting started, make sure you have the following installed and configured on your system:
- Node.js (version 14 or higher) - Download Node.js
- npm (usually installed with Node.js) or yarn
- Git - Download Git
- A code editor like Visual Studio Code - Download VS Code
- A PostgreSQL account (you can use a service like Neon for a hosted PostgreSQL database)
Also, ensure you have a basic understanding of React, Next.js, and TypeScript to make the most of this template.
Getting Started
- Clone the repository:
git clone https://github.com/ClementG91/Next-Template.git
- Navigate to the project directory:
cd Next-Template
- Install dependencies:
npm install
- Configure environment variables:
Copy the
.env.examplefile to.envand fill in the necessary values:cp .env.example .env
Open the
.envfile and update the following variables:POSTGRES_URL,POSTGRES_PRISMA_URL,POSTGRES_URL_NO_SSL,POSTGRES_URL_NON_POOLING: Your PostgreSQL database URLsPOSTGRES_USER,POSTGRES_HOST,POSTGRES_PASSWORD,POSTGRES_DATABASE: Your PostgreSQL connection informationNEXTAUTH_SECRET: A random string for NextAuth.jsNEXTAUTH_URL,NEXT_PUBLIC_BASE_URL: Your application's URLDISCORD_CLIENT_ID,DISCORD_CLIENT_SECRET: Your Discord client credentialsGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET: Your Google client credentialsEMAIL_SERVER_HOST,EMAIL_SERVER_PORT,EMAIL_SERVER_USER,EMAIL_SERVER_PASSWORD,EMAIL_FROM,EMAIL_TO: Your SMTP server configuration for sending emails
- Set up the database:
npx prisma db push
npx prisma generate
- Start the development server:
npm run dev
- Build the application:
npm run build
Your application should now be running on http://localhost:3000.
Key Technologies
Project Structure
app/: Next.js 13+ App Router structurelayout.tsx: Root layout componentpage.tsx: Home page component(auth)/: Authentication-related pages(user)/: User-related pages (e.g., dashboard)
components/: Reusable React componentsui/: UI components (buttons, cards, etc.)layout/: Layout components (navbar, footer)pages/: Page-specific components
lib/: Utility functions and configurationsprisma.ts: Prisma client instanceauth.ts: NextAuth.js configuration
prisma/: Database schema and migrationsschema.prisma: Prisma schema file
public/: Static assetstypes/: TypeScript type definitions
Customization
This template is designed to be highly customizable. Here are some key areas you can modify:
- Tailwind CSS configuration:
Edit
tailwind.config.jsto customize colors, fonts, and other design tokens. - Authentication providers:
Modify
lib/authOptions.tsto add or remove authentication providers. - API routes:
Add or modify API routes in the
app/apidirectory. - Database schema:
Extend the Prisma schema in
prisma/schema.prismafor new data models. - UI components:
Customize existing components or add new ones in the
components/uidirectory.
Further Reading
- Authentication Guide: Detailed explanation of the authentication system and how to customize it.
- Database Management with Prisma: How to work with the database, create migrations, and extend the schema.
- Working with API Routes: Guide on creating and using API routes in Next.js.
- Deployment Guide: Steps to deploy your application to various platforms.