start-core-auth-server-primitives

Implement server-side session, OAuth, CSRF, and rate-limiting primitives for TanStack Start applications.

Updated Dec 21, 2025
One-click install
npx skills add https://github.com/Angael/veles --skill start-core-auth-server-primitives-angael
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: start-core-auth-server-primitives
Source: https://github.com/Angael/veles/tree/main/.agents/skills/start-core-auth-server-primitives
Command: npx skills add https://github.com/Angael/veles --skill start-core-auth-server-primitives-angael

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-start, @tanstack/react-router, zod.

What problem does it solve? Building authentication in TanStack Start requires correctly wiring session cookies, middleware, OAuth flows, and endpoint hardening on the server side, and mistakes like trusting route guards or leaking user existence create real security holes. ## Core Features & Use Cases - Session Management: Issue, read, rotate, and destroy sessions using HttpOnly, Secure, SameSite cookies with the __Host- prefix, loaded through createMiddleware. - OAuth and Login Hardening: Implement the authorization-code flow with state and PKCE, defeat user enumeration in login and password-reset endpoints, and rotate sessions on privilege changes. - Endpoint Defense: Add CSRF origin checks for non-GET RPCs and sliding-window rate limiting on login, registration, and reset endpoints. - Use Case: You are adding login to a TanStack Start app and need every server function that touches private data to reject unauthenticated calls, even when invoked directly without visiting a guarded route. ## Quick Start Ask the AI to implement a login server function in TanStack Start with a secure session cookie, auth middleware, and rate limiting.

Frequently Asked Questions about start-core-auth-server-primitives

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

FAQPage Schema
How do I implement session authentication in TanStack Start?

Store an opaque session token in an HttpOnly, Secure, SameSite=Lax cookie with the __Host- prefix, then load it in createMiddleware so every protected server function receives a typed session. Read the cookie inside .handler() or middleware .server(), never at module scope.

How do I protect server functions in TanStack Start?

Attach an auth middleware to every server function that touches private data, because route guards with beforeLoad do not protect RPCs called directly. The middleware validates the session token and throws Unauthorized before the handler runs.

Does a route guard protect TanStack Start server functions?

No, a beforeLoad redirect on an _authenticated layout only affects page navigation. Server functions remain reachable via direct POST requests, so auth must be enforced inside the handler or through middleware on each function.

How do I implement OAuth with PKCE in TanStack Start?

Generate a random state and PKCE verifier, store both in a short-lived signed HttpOnly cookie, and redirect to the provider with the S256 code challenge. In the callback, verify the returned state matches the cookie before exchanging the code with the verifier.

Why is reading cookies at module scope a problem in TanStack Start?

Module-level code runs before any request exists, so request headers and cookies are unavailable. On edge runtimes like Cloudflare Workers, environment variables are also injected per-request, making module-scope reads evaluate to undefined.

How do I prevent user enumeration in password reset endpoints?

Return the same 200 response and identical body whether or not the email exists, and perform equivalent work in both branches to avoid timing leaks. Never use different messages or status codes that reveal account existence.