nextjs-16-use-server-exports

Move non-function exports from Next.js 16 use server files to separate constants.

1|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/Hankanman/claude-config --skill nextjs-16-use-server-exports
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-16-use-server-exports
Source: https://github.com/Hankanman/claude-config/tree/main/config/skills/nextjs-16-use-server-exports
Command: npx skills add https://github.com/Hankanman/claude-config --skill nextjs-16-use-server-exports

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps fix build errors caused by non-async exports in files that use the Next.js 16 "use server" directive. By isolating constants, enums, or type exports into a separate non-server module and updating imports, you maintain server action safety and ensure successful builds.

Core Features & Use Cases

  • Separation of concerns: move non-function exports out of server-action files into a dedicated constants file without a "use server" directive.
  • Safe server actions: keep all exported async functions in server files to satisfy Next.js 16 requirements.
  • Use case examples: when a server file exports AUDIT_ACTIONS or schema-like objects alongside server actions, this pattern prevents build failures and improves maintainability.

Quick Start

Inspect the server file to identify any non-function exports, create a new non-server constants file, update imports, and run a build to verify the issue is resolved.

Frequently Asked Questions about nextjs-16-use-server-exports

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does Next.js 16 throw a build error for non-async exports in use server files?

Next.js 16 requires 'use server' files to export only async functions. Including constants, enums, or types in these files violates server action safety rules and triggers build errors during compilation.

How do I fix use server build errors caused by exporting constants?

Fix this by moving non-function exports into a dedicated non-server constants file. Update your project imports to reference the new module, ensuring the 'use server' file retains only async functions for successful builds.

Can I export enums or schema objects from a Next.js server actions file?

No, exporting enums or schema objects from a server actions file causes build failures. Isolate these non-function exports into a standard non-server module to maintain server action safety and ensure successful compilation.

What is the best way to separate constants from server actions in Next.js 16?

The best way is creating a dedicated constants file without a 'use server' directive. Move enums and schemas there, update project imports, and leave only async functions in the server file to maintain separation of concerns.

Does Next.js 16 allow type exports alongside async server actions?

No, Next.js 16 does not allow type exports alongside async server actions in a 'use server' file. Relocate type exports to a separate non-server module to satisfy strict directive requirements and avoid build errors.