Next.js Performance Optimization

VerifiedSafe

Focuses on critical Next.js performance fixes: prevents asynchronous waterfalls via Promise.all and Suspense, reduces bundle size by banning barrel imports and using next/dynamic for heavy components, secures Server Actions with mandatory internal authentication, and enforces proper production build practices. Ideal when writing React components, data fetching logic, Server Actions, or optimizing bundle size in Next.js applications.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#nextjs#performance#react#server-actions#bundle-size

Recommended for

Automated summary

Prevents async waterfalls, reduces bundle size, secures Server Actions, and ensures correct production builds in Next.js applications.

Strengths

  • Promotes best practices for data fetching with Promise.all
  • Reduces bundle size by avoiding barrel imports and using dynamic imports
  • Ensures security by checking authentication inside Server Actions

Limitations

  • Focuses on specific Next.js patterns and may not cover all performance issues
  • Requires familiarity with Next.js concepts like Server Actions and dynamic imports
When to use it

Use when writing React components, data fetching, Server Actions, or optimizing bundle size in a Next.js project.

When not to use it

Not suitable for non-Next.js projects or when simple static pages without server-side logic.

Security analysis

Safe
Quality score85/100

The skill provides performance and security best practices for Next.js development without executing any commands, accessing external resources, or disabling safety features. It instructs on code patterns, not on system-modifying actions.

No concerns found

How this analysis is made

Examples

Optimize data fetching
Help me optimize data fetching in my Next.js app to avoid waterfall requests.
Reduce bundle size
How can I reduce bundle size in Next.js by avoiding barrel imports?
Secure Server Actions
Show me how to properly secure Server Actions in Next.js.

name: nextjs-performance description: | Next.js critical performance fixes. Prevents async waterfalls, reduces bundle size, secures Server Actions, and ensures correct production builds. Use when writing React components, data fetching, Server Actions, or optimizing bundle size.

Next.js Performance

Before Writing Code

  1. Read docs/agent/architecture/nextjs-critical-fixes.md for full patterns
  2. Check existing components in apps/frontend/components/

Critical Rules

Waterfalls

  • Use Promise.all() for independent fetches
  • Wrap slow data in <Suspense> boundaries
  • Defer await into branches where needed
// WRONG
const resumes = await fetchResumes();
const jobs = await fetchJobs();

// RIGHT
const [resumes, jobs] = await Promise.all([fetchResumes(), fetchJobs()]);

Bundle Size

  • NO barrel imports: import X from 'lucide-react' is WRONG
  • YES direct imports: import X from 'lucide-react/dist/esm/icons/x'
  • Use next/dynamic for heavy components (editors, charts, PDF)
  • Defer analytics with ssr: false
import dynamic from 'next/dynamic';
const HeavyEditor = dynamic(() => import('./HeavyEditor'), { ssr: false });

Server Actions

  • ALWAYS check auth INSIDE the action, not just middleware
  • Verify resource ownership before mutations

Production Build

  • Run npm run build && npm run start, NOT npm run dev
  • Docker must use standalone output

Pre-PR Checklist

[ ] No sequential awaits for independent data
[ ] Icons imported directly (not barrel)
[ ] Heavy components use next/dynamic
[ ] Server Actions have auth inside
[ ] Suspense around slow fetches

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/next-js-performance-optimization-mm5t8abm' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/next-js-performance-optimization-mm5t8abm/download' --output '.skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md.part' && mv '.skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md.part' '.skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md' && test -s '.skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nextjs-performance' && cp -R '.skill-downloads/next-js-performance-optimization-mm5t8abm' '.claude/skills/nextjs-performance'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/next-js-performance-optimization-mm5t8abm'

openskills read 'next-js-performance-optimization-mm5t8abm'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/next-js-performance-optimization-mm5t8abm/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills