Skip to content

Best Practices for Structuring a Full-Stack Next.js Project? #151820

Discussion options

You must be logged in to vote

Recommended Folder Structure & Best Practices for Next.js 🚀

Hey! 👋 Here’s a solid approach for structuring your full-stack Next.js project:

📂 Folder Structure

/app/api        # API routes (Next.js App Router)
/components     # Reusable UI components
/hooks          # Custom React hooks
/lib            # Database queries & utilities
/context        # State management (if using Context API)
/services       # External API calls
/models         # Database models (if using Prisma/Drizzle)
/config         # Env & project configs

💾 Database Handling (PostgreSQL)

  • Prisma (Recommended):
    Define models in /prisma/schema.prisma & queries in /lib/db.ts:
    import { PrismaClient } from '@prisma/client';
    c…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Dev-Emmyy
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Programming Help Programming languages, open source, and software development.
3 participants