Beautiful, framework-agnostic sign-in buttons for OpenRouter OAuth. No client registration, no backend, no secrets.
The copy-pasteable OAuth skill (auth module + SignInButton component) lives in the OpenRouter Skills repo:
skills/openrouter-oauth/SKILL.md
Install it in your AI coding agent:
| Agent | Command |
|---|---|
| Claude Code | /plugin marketplace add OpenRouterTeam/skills → /plugin install openrouter@openrouter |
| Cursor | Settings > Rules > Add Rule > Remote Rule: OpenRouterTeam/skills |
| Skills CLI | npx skills add OpenRouterTeam/skills |
Or just copy SKILL.md directly into your project.
The skill gives you two files to drop into any project:
-
lib/openrouter-auth.ts— Framework-agnostic PKCE OAuth flow using plainfetch. Handles verifier generation, redirect, code exchange, key storage inlocalStorage, and cross-tab sync. -
components/sign-in-button.tsx— Styled button with the OpenRouter logo, 5 variants, 4 sizes, and dark mode support.
Works with React, Vue, Svelte, vanilla JS, or any framework.
| Variant | Description |
|---|---|
default |
White bordered button with logo |
minimal |
Text-only, underline on hover |
branded |
Dark background, white text |
icon |
Logo only, square |
cta |
Landing page button with scale effect |
- User clicks the sign-in button
- Browser redirects to
https://openrouter.ai/authwith a PKCE code challenge - User authorizes on OpenRouter
- OpenRouter redirects back with
?code= - App exchanges the code for an API key via
POST /api/v1/auth/keys - Key is stored in
localStorage— ready to use with any OpenRouter model
This repo contains the reference implementation and demo web app:
src/lib/— Auth module with full error handling, SSR safety, cross-tab syncsrc/components/— SignInButton with CVA variants, OpenRouterLogo SVGsrc/hooks/— React context provider (OpenRouterAuthProvider) anduseOpenRouterAuthhooksrc/demo/— Interactive demo deployed to GitHub Pages
npm install
npm run dev # Demo at localhost:5173
npm run build:demo- API keys are stored in
localStorage— any JavaScript on the page can access them. This is a known tradeoff for backend-less apps. - The PKCE code verifier is stored in
sessionStorage(per-tab, cleared on tab close). - Consider Content Security Policy and XSS protections for production apps.
MIT