create-api-route

Generates server-side Next.js API routes for Supabase authentication and session management.

Updated May 27, 2026
One-click install
npx skills add https://github.com/Rkaaaa404/cyberhack-SYDT --skill create-api-route-rkaaaa404
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: create-api-route
Source: https://github.com/Rkaaaa404/cyberhack-SYDT/tree/main/.agents/skills/create-api-route
Command: npx skills add https://github.com/Rkaaaa404/cyberhack-SYDT --skill create-api-route-rkaaaa404

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires next, @supabase/ssr, @supabase/supabase-js, zod, and includes references (resource) components.

What problem does it solve? Building secure server-side auth endpoints in a Next.js + Supabase SSR stack requires repetitive boilerplate for cookie handling, session checks, and error responses. This Skill generates consistent, production-patterned auth routes (login, logout, callback, user) so you avoid re-implementing the same logic and making auth mistakes. ## Core Features & Use Cases - Auth Route Generation: Creates app/api/auth/ routes for login (signInWithPassword), logout (signOut), OAuth/magic-link callback code exchange, and current-user session retrieval. - DaaS-Compatible Patterns: Provides reference implementations for REST endpoints with DaaS-style query parameters (fields, filter, sort, limit, offset, aggregate), Zod validation, and standardized { data } / { errors } response formats. - Authorization Enforcement: Reference guides cover permission enforcement via enforcePermission(), field-level access control, item-level filters, and a reusable error handler mapping Supabase/Postgres error codes to HTTP statuses. - Use Case: You need a login endpoint for your Supabase-backed Next.js app. Invoke this Skill to scaffold app/api/auth/login/route.ts with proper SSR cookie handling, auth checks, and tests. ## Quick Start Ask the assistant to create a Supabase login API route for your Next.js app using this skill.

Frequently Asked Questions about create-api-route

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

FAQPage Schema
How do I create a Supabase login API route in Next.js?▼

Create `app/api/auth/login/route.ts` with a POST handler that uses the server-side Supabase client to call signInWithPassword. The SSR client manages HTTP-only session cookies automatically, and you return the session data or an error response.

Should I build Next.js API proxy routes for my DaaS data?▼

No. The UI should call DaaS directly using an Authorization Bearer header with the Supabase JWT, and CORS is handled by the DaaS CORS_ORIGINS environment variable. Only auth routes (login, logout, callback, user) need to exist server-side.

How do I handle OAuth callback in a Next.js Supabase app?▼

Create a GET route at `app/api/auth/callback/route.ts` that exchanges the authorization code from the URL for a session using the server-side Supabase client. This works for both OAuth providers and magic-link sign-ins.

Why does my DaaS query return a 500 error when sorting?▼

A 500 error usually means the sort or filter field name does not exist in the DaaS schema, such as using date_created when the column is created_at. Verify field names with the schema or fields MCP tools before using them in sort, fields, or filter parameters.

How do I validate request bodies in Next.js API routes?▼

Use Zod to define a schema for the expected payload, then call schema.parse(body) inside the handler. Validation failures throw a ZodError that your error handler can map to a 400 response with per-field messages.