Skip to main content

Next.js Prompt to Generate a Full-Stack App Router CRUD App

Scaffold a full-stack Next.js App Router CRUD app fast: Prisma schema, server actions, server and client components, auth, and optimistic UI updates.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Generate a full-stack Next.js 14 App Router CRUD application for Blog Posts. Include: 1) Prisma schema with PostgreSQL database, 2) Server Actions for create, read, update, delete, 3) Server Components for data fetching, 4) Client Components for forms with react-hook-form, 5) Authentication using NextAuth.js v5, 6) Optimistic UI updates with useOptimistic, 7) Error boundaries and loading.tsx skeletons, 8) Tailwind CSS + shadcn/ui styling with responsive design, 9) Search, pagination, and sorting, 10) Zod validation shared between client/server. Include middleware for auth protection.

What this prompt does

This prompt scaffolds a full-stack Next.js App Router CRUD application for one resource, wiring the database, server logic, and UI together. It generates a Prisma schema, Server Actions for create/read/update/delete, Server Components for fetching, Client Components for forms, authentication, optimistic UI with useOptimistic, error boundaries and loading skeletons, styling, search/pagination/sorting, and Zod validation shared between client and server.

The variables pin the stack. [nextjs_version] and [resource_name] define the target and the entity, [database] sets what Prisma connects to, and [form_library] (react-hook-form) handles form state. [auth_provider] chooses the auth solution and [styling] the visual approach (Tailwind plus shadcn/ui). The standout design choice is shared Zod validation: the same schema runs on the client and inside Server Actions, so the two can't drift out of sync. Optimistic updates with useOptimistic plus proper loading.tsx and error boundaries make the app feel fast and resilient, and getting auth middleware in from the start avoids a painful retrofit.

When to use it

  • Spinning up a new App Router feature with full CRUD quickly
  • Building forms whose validation is guaranteed identical on client and server
  • Adding optimistic UI so actions feel instant before the server confirms
  • Scaffolding a resource that needs search, pagination, and sorting out of the box
  • Setting up auth-protected routes via middleware from day one
  • Establishing a Server Actions plus Prisma pattern other features can follow

Example output

You get a Prisma schema for [resource_name] targeting [database], a set of Server Actions for each CRUD operation, Server Components that fetch and render data, Client Components with [form_library] forms, auth wiring via [auth_provider], optimistic update handling, loading.tsx skeletons, error boundaries, and [styling]-based responsive UI. Zod schemas are imported by both the client form and the server action. Middleware protects the routes. The result is a coherent vertical slice rather than disconnected snippets.

Pro tips

  • Set [nextjs_version] accurately; App Router APIs like useOptimistic and Server Actions have shifted across versions, and a mismatch causes runtime errors
  • Keep one Zod schema per resource and import it in both places — that single source of truth is the whole point of the shared-validation approach
  • Confirm the [auth_provider] version matches your install (NextAuth v5 differs significantly from v4) before running the generated middleware
  • Use optimistic updates only where a failure is recoverable; for destructive actions, prefer confirming with the server first
  • Verify the Prisma schema's relations and indexes for your [database]; the AI infers a reasonable shape but won't know your query patterns
  • Treat loading.tsx and error boundaries as required, not optional — they're what keep the UI solid when a fetch is slow or fails

Frequently Asked Questions

How does shared Zod validation prevent client and server drifting?
The same Zod schema is imported by the client form and the server action, so both validate against identical rules. If you change a constraint, both sides update at once, which eliminates the common bug where client validation passes but the server rejects the data.
Does it work with any Next.js version?
You specify the version, but App Router features like Server Actions and useOptimistic changed across releases. Set the version variable to match your install, and verify the generated APIs exist in that version before relying on the scaffold.
Can I use a different auth provider than NextAuth?
Yes, the auth provider is a variable you can set to your preferred solution. Just be aware that the generated middleware and session handling assume the provider you name, and major version differences within a provider can change the API significantly.
Should I use optimistic updates for delete actions?
Be cautious. Optimistic UI feels great for recoverable changes, but for destructive operations like delete it can show success before the server confirms. For those, confirming with the server first is usually safer than rolling back a failed optimistic update.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in React & Next.js Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support