Next.js Security

Enforce Next.js App Router security with Zod validation and server-only markers.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill next-js-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Next.js Security
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/nextjs/security
Command: npx skills add https://github.com/Mte90/dotfiles --skill next-js-security

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses critical security vulnerabilities in Next.js applications, particularly within the App Router and Server Actions, ensuring data integrity and preventing common attack vectors.

Core Features & Use Cases

  • Input Validation: Enforces strict data validation for all incoming data using Zod schemas.
  • Data Boundary Enforcement: Prevents sensitive data leakage from server components to client components.
  • Server-Side Security: Implements server-only markers and middleware for route protection.
  • Use Case: Protect your Next.js application by ensuring all form submissions to Server Actions are validated, preventing unauthorized data modifications and security breaches.

Quick Start

Use the Next.js Security skill to validate form data for the 'submit' action in 'app/users/actions.ts'.

Frequently Asked Questions about Next.js Security

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

FAQPage Schema
How do I validate form data in Next.js Server Actions?

To validate form data in Next.js Server Actions, use Zod schemas to strictly validate all incoming JSON and form inputs. This prevents unauthorized data modifications and ensures data integrity before processing.

How do I prevent data leakage from RSC to client components in Next.js?

Prevent data leakage from RSC to client components by enforcing strict data boundaries. This ensures sensitive server-side information is not exposed to the client, maintaining secure data separation.

What is the best way to secure Next.js App Router routes?

The best way to secure Next.js App Router routes is by implementing server-only markers and middleware for route protection. This enforces core security standards and sanitizes inputs effectively.

Does this enforce input sanitization for Next.js middleware?

Yes, it enforces input sanitization for Next.js middleware. It utilizes middleware to protect routes and sanitize incoming data, addressing critical security vulnerabilities within the App Router architecture.

Can I use Zod to enforce security standards in Next.js?

Yes, you can use Zod to enforce security standards in Next.js. It validates all form and JSON input using Zod schemas, ensuring strict data validation for Server Actions.