10 Aug 2025

By
Kate Baker

A solid folder structure is key to building scalable, maintainable, and high-performing Next.js applications. In this post, we’ll walk through how to organize your Next.js 15 project the right way.
Here’s a tried-and-true structure tailored for modern Next.js projects:



app/ – Application Routing(auth), (dashboard))components/ – UI Elementsui/, shared/, and dashboard/lib/ – External Setup// lib/firestore.ts
import { Firestore } from '@google-cloud/firestore'
const firestore = new Firestore({
projectId: process.env.GOOGLE_CLOUD_PROJECT,
databaseId: process.env.GOOGLE_CLOUD_DATABASE_ID,
})
export default firestoreservices/ – Business Logic Layerhooks/ – Reusable Logiccontexts/ – Shared Application Stateutils/ – Utility Helperstypes/ – Type Declarationsstyles/ – Global Stylestests/ – Application Testingnext/dynamic to lazy-load heavy components/app/api/// Example API handler
import { NextResponse } from 'next/server'
import firestore from '@/lib/firestore'
export async function GET(req: Request) {
const snapshot = await firestore.collection('users').get()
const users = snapshot.docs.map(doc => doc.data())
return NextResponse.json({ users })
}By following this structure, your Next.js project will stay clean, scalable, and ready to grow — no matter how complex it gets.

If you want a self-hosted alternative of Google Photos, Immich is currently the most polished choice. It’s a self-hosted photo management tool with fast mobile backups, face & object search, albums and shared libraries, a slick web UI, and strong privacy by design.

A solid folder structure is key to building scalable, maintainable, and high-performing Next.js applications. In this post, we’ll walk through how to organize your Next.js 15 project the right way.