1.0.2 ⢠Published 6 months ago
create-ultimate-app v1.0.2
Next.js Template with Authentication, Prisma, and Shadcn UI
By : Anurag Maurya | my github | twitter
This is a modern Next.js template that includes authentication with NextAuth.js, Prisma ORM, and Shadcn UI components.
Features
- š Authentication with Google (NextAuth.js)
- š Database ORM with Prisma
- šØ UI Components from Shadcn UI
- š Dark mode support
- š Next.js 14 with App Router
- ā” Turbopack for faster development
- šØ Tailwind CSS for styling
- š± Responsive design
- š TypeScript support
Prerequisites
Before you begin, ensure you have installed:
- Node.js 18+
- PNPM package manager
- PostgreSQL database
Getting Started
- Set up your environment variables by creating a
.env
file in the root directory:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/your_database_name"
# Authentication (Google)
GOOGLE_CLIENT_ID="your_google_client_id"
GOOGLE_CLIENT_SECRET="your_google_client_secret"
# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your_nextauth_secret" # Generate with: openssl rand -base64 32
- Set up the database:
# Generate Prisma Client
pnpm prisma generate
# Run database migrations
pnpm prisma migrate dev
# (Optional) Seed the database
pnpm prisma db seed
- Start the development server:
pnpm dev
Open http://localhost:3000 with your browser to see the result.
Google OAuth Setup
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Go to Credentials ā Create Credentials ā OAuth Client ID
- Set up the OAuth consent screen
- Create OAuth 2.0 Client ID
- Add authorized redirect URI: `http://localhost:3000/api/auth/callback/google`
- Copy the Client ID and Client Secret to your
.env
file
Database Schema
The current schema includes a User model with basic fields. You can extend it by modifying `prisma/schema.prisma`:
model User {
id String @id @default(cuid())
email String @unique
name String
avatar String
updatedAt DateTime @updatedAt
}
Available Scripts
# Development
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run ESLint
# Database
pnpm prisma studio # Open Prisma Studio
pnpm prisma generate # Generate Prisma Client
pnpm prisma migrate dev # Run migrations in development
pnpm prisma migrate deploy # Deploy migrations in production
Project Structure
āāā src/
ā āāā app/ # App router pages
ā āāā components/ # React components
ā ā āāā ui/ # Shadcn UI components
ā ā āāā ... # Custom components
ā āāā lib/ # Utility functions
ā ā āāā auth/ # Authentication logic
ā ā āāā db/ # Database utilities
ā āāā ...
āāā prisma/ # Prisma schema and migrations
āāā public/ # Static files
āāā ...
Deployment
This template is ready to be deployed on Vercel. For other platforms, ensure you:
- Set up all environment variables
- Run database migrations
- Build the project
- Start the production server