nextjs-file-conventions

Document Next.js 16 App Router file conventions with TypeScript signatures.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/xabierlameiro/price-tracker --skill nextjs-file-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-file-conventions
Source: https://github.com/xabierlameiro/price-tracker/tree/main/.agents/skills/nextjs-file-conventions
Command: npx skills add https://github.com/xabierlameiro/price-tracker --skill nextjs-file-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill clarifies the complex and often confusing file conventions within the Next.js App Router, helping developers understand where to place files and what their purpose is.

Core Features & Use Cases

  • File Convention Reference: Provides a comprehensive overview of special files like layout.tsx, page.tsx, route.ts, proxy.ts, and metadata files.
  • API Details: Explains required and optional exports, props, and segment configuration options for each file type.
  • Use Case: When you're unsure whether to use layout.tsx or template.tsx for a specific UI segment, or how to configure an API route, this Skill provides the definitive answer.

Quick Start

Explain the purpose and usage of route.ts files in Next.js.

Frequently Asked Questions about nextjs-file-conventions

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

FAQPage Schema
What are the special file conventions in Next.js App Router?

Next.js App Router file conventions dictate special files like layout.tsx, page.tsx, loading.tsx, error.tsx, and route.ts. This reference details their purpose, required exports, props, and TypeScript signatures for structuring your application's routing and UI segments.

How do I use route.ts to create API routes in Next.js?

To create API routes in Next.js, use the route.ts file convention. This Skill explains the required and optional exports, segment configuration options, and request handling props needed to define and manage server-side endpoints within the App Router.

When should I use template.tsx instead of layout.tsx in Next.js?

Use template.tsx instead of layout.tsx in Next.js when you need a component to re-render and reset state upon navigation. This reference explains the distinct sub-segment behavior and props for both file conventions to help you choose the correct UI wrapper.

What is the purpose of proxy.ts and instrumentation.ts in Next.js?

In Next.js, proxy.ts and instrumentation.ts are special file conventions for specific routing and observability tasks. This Skill outlines their exact exports, configuration options, and use cases to help you manage requests and monitor your application.

How do I handle loading and error states using Next.js file conventions?

Next.js handles loading and error states using the loading.tsx and error.tsx file conventions. This reference provides their TypeScript signatures, props, and sub-segment behavior to help you implement resilient UI fallbacks for route segments.

Can I configure metadata files for SEO in the Next.js App Router?

Yes, you can configure metadata files for SEO in the Next.js App Router. This Skill details the specific metadata file conventions, their required exports, and how they interact with layout.tsx and page.tsx to manage your application's metadata.