AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Nextjs App Architecture

skill-aurorascharff-skills-nextjs-app-architecture · by aurorascharff

Architecture patterns for Next.js 16 App Router apps. Use when scaffolding a new app, adding a feature, refactoring code into feature folders, deciding where queries/actions/components live, placing Suspense boundaries, choosing the client/server boundary, designing skeletons, preventing CLS, or enabling Cache Components. Also use when the user asks about RSC composition, `params.then()`, `'use c…

No reviews yet
0 installs
29 views
0.0% view→install

Install

$ agentstack add skill-aurorascharff-skills-nextjs-app-architecture

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-aurorascharff-skills-nextjs-app-architecture)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Nextjs App Architecture? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Next.js App Architecture

Use when building or refactoring Next.js 16+ App Router apps. The skill is organized into focused references — load only the ones relevant to the current task.

When to read which reference

The references are split into two zones. Load only what the task calls for.

Core (load for any RSC Next.js app)

| Task | Read | | ----------------------------------------------------------------------- | ------------------------------- | | Creating a new feature, deciding folder structure, naming files | references/feature-folders.md | | Writing a query or server action, invalidating cached data | references/queries-actions.md | | Building a server/client component, designing a skeleton, using use() | references/components.md | | Composing a page, placing `, preventing CLS | references/pages-suspense.md` |

Instant Apps (load only when optimizing for instant-feeling apps)

These build on the core; they're opt-in opinions, not architecture requirements.

| Task | Read | | ------------------------------------------------------------------------------------- | -------------------------------- | | Turning on cacheComponents, adding 'use cache' / cacheTag / updateTag | references/cache-components.md | | useOptimistic for mutations, toasts, pending state, action-prop pattern, pagination | references/ux-patterns.md |

Read references in addition to, not instead of, this overview. Each one assumes the rules below already apply.

The model

Next.js 16+ App Router with React Server Components. Three high-level patterns shape everything else:

  1. Feature-sliced layout — domain folders under features/, each owning its queries, actions, and components. Pages in app/ compose features; they never contain domain logic.
  2. Async server components by default — components await their own queries directly. Client components ('use client') are leaves, not parents, of the tree.
  3. Suspense at the page — the feature exports content + a sibling skeleton. The page imports both and places the `` boundary.

Decision rules (always apply)

These rules apply to every change. If you violate one, you'll fight the framework later.

  • Pages never fetch data directly. They compose feature components.
  • Pages stay synchronous. Use params.then() instead of await params so the page chrome above the .then() paints immediately and only the data-dependent section suspends. (Required for the static shell when Cache Components is on; still a nice-to-have without it.) See references/pages-suspense.md.
  • Queries live in -queries.ts with import 'server-only' and cache() wrapping every export. See references/queries-actions.md.
  • Actions live in -actions.ts with 'use server' at the top. The file name matches the folder, even when the mutation targets a sub-concept. See references/feature-folders.md and references/queries-actions.md.
  • Async server component is the default. Add 'use client' only when you need hooks, event handlers, or browser APIs. See references/components.md.
  • The page owns the Suspense boundary; the feature owns the skeleton. Don't pre-wrap components in ` inside the feature. See references/pages-suspense.md`.
  • Skeletons live in the same file as the component. Feed and FeedSkeleton are sibling exports. See references/components.md.
  • Single-use sub-components stay inlined as non-exported functions in the same file. Exports are for things other files import. See references/components.md.

Decision flow for a new feature

1. Does a feature folder for this domain already exist?
   → Yes: use it. Don't make a new one.
   → No: is this a real domain noun, or a sub-concept of an existing one?
        → Sub-concept (favorite, like, vote, bookmark): fold into the parent feature.
        → Real domain: create features//.

2. Add the query
   → features//-queries.ts
   → Wrap in cache(). If using Cache Components, also add 'use cache' + cacheTag.
   → See references/queries-actions.md (core) and references/cache-components.md (Cache Components).

3. Add the action (if there's a mutation)
   → features//-actions.ts
   → 'use server' at the top, validate input, refresh() (or updateTag() with Cache Components) to invalidate.

4. Build the component
   → features//components/.tsx
   → async server component that awaits its query
   → Export  and  from the same file.

5. Compose the page
   → app//page.tsx
   → Keep the page synchronous, use params.then().
   → Place }>.

Pitfalls

  • Passing server actions as props to call them. Client components import actions directly.
  • Refetching what the parent already has. Server components take plain values, not promises. If ` queried the list, pass each post to `, don't refetch by id.
  • Inlining route-specific components in the page file. Extract them into the feature folder. The page should not grow past composition.
  • Splitting a card and its grid into separate files. They're always used together. One file, multiple exports.
  • Making a feature folder for one query, one action, one button. Fold it into the parent feature.
  • Using 'use cache' without cacheComponents: true. They go together. See references/cache-components.md.
  • Wrapping the entire page in a Suspense fallback. Page chrome paints instantly, only data-dependent sections suspend. See references/pages-suspense.md.

Reference index

Core

  • references/feature-folders.md — Folder layout, naming, merging sub-concepts, when a new folder is justified, action/query file naming.
  • references/queries-actions.md — Server-only queries, cache() for dedup, server actions, validation, refresh() for invalidation.
  • references/components.md — Async server components, skeletons, client boundary, promise + use() pattern, single-use helpers, polling for live data.
  • references/pages-suspense.md — Page composition, PageProps / LayoutProps, params.then(), Suspense placement rules, CLS prevention, error boundaries, layout-level Suspense.

Instant Apps (opt-in)

  • references/cache-components.mdcacheComponents: true model, the static shell, 'use cache' / 'use cache: private' / 'use cache: remote', cacheTag / cacheLife strategy, updateTag / revalidateTag invalidation, connection() escape hatch, build constraints.
  • references/ux-patterns.mduseOptimistic for mutations, toasts, pending state via data-pending, destructive action flows, the action-prop pattern, URL pagination, useFormStatus.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.