Next.js App Router Snippets
March 5, 2026 · View on GitHub
Snippets for faster and consistent development with the Next.js App Router.
Features
- 15+ Snippets – Coverage for all major App Router file types
- Context-Aware – Snippets appear only in matching file patterns
- App Router‑Optimized — Pages, layouts, error boundaries, metadata, loading states
- TypeScript‑Native – Designed for
.tsxfiles - Best‑Practice Templates – Encourages idiomatic Next.js structure
- Time Saving – Reduce boilerplate and follow Next.js best practices
Usage
- Install the extension from the VS Code Marketplace or manually from the VSIX package.
- Open a TypeScript React (
.tsx) file in your Next.js project. - Type a snippet prefix (e.g.,
appRoutePage,appRouteNotFound). - Select the snippet from IntelliSense.
- The snippet will expand into a ready-to-use code template.
Context-Aware Snippets
Note: Not every snippet is available in every
.tsxfile. Each snippet is context-aware and will only appear in files that match specific patterns. For example, a snippet for anot-found.tsxpage will only be suggested in files namednot-found.tsxwithin theappdirectory. This keeps IntelliSense clean and ensures snippets appear only where they make sense.
Example Snippet Prefixes & Where They Work
| Prefix | Where it works |
|---|---|
appRouteNotFound | **/app/**/not-found.tsx |
appRouteUnauthorized | **/app/**/unauthorized.tsx |
appRouteForbidden | **/app/**/forbidden.tsx |
appRouteError | **/app/**/error.tsx |
appRouteLoading | **/app/**/loading.tsx |
appRoutePage | **/app/**/page.tsx or **/app/**/[slug]/page.tsx |
appRouteSearchPage | **/app/**/page.tsx or **/app/**/[slug]/page.tsx |
appRouteLayout | **/app/**/layout.tsx |
appRouteMetadata | **/app/**/page.tsx or **/app/**/layout.tsx |
appRouteStaticParams | [slug]/page.tsx, [slug]/layout.tsx, or [slug]/route.ts |
appRouteAction | **/app/**/page.tsx , **/lib/**/*.ts, **/app/**/actions.ts or **/actions/**/*.ts |
appRouteClientComponent | **/ui/**/*.tsx, **/*provider.tsx or **/components/**/*.tsx |
See the full list of filters and prefixes in the snippets file.
Requirements
- Visual Studio Code v1.109.0 or higher
- Next.js project using the App Router
Installation
From VS Code Marketplace
- Open VS Code
- Go to the Extensions view (
Ctrl+Shift+X/Cmd+Shift+X) - Search for
Next.js App Router Snippets - Click Install
Manual Installation from VSIX
- Download the latest
.vsixfile from Releases - In VS Code, press
Ctrl+Shift+Pand runExtensions: Install from VSIX... - Select the downloaded file and click Open
Contributing
Contributions are welcome. Please read the Contributing Guide for details on:
- reporting bugs
- requesting new snippets or improvements
- submitting pull requests
- following code standards and project structure
Support
- 🐛 Issues
- 💡 Feature Requests
- 📄 Changelog
License
This project is licensed under the MIT License – see the LICENSE file for details.
Maintained by the community. Contributions are welcome.