React Router v7 / Remix (framework mode)
Resource routes for sign-in and a loader check in the root layout.
Register the app first: ask your agent, or create a web app in the dashboard with redirect URI http://localhost:5173/auth/callback.
Environment
.envYOURSELF_ISSUER=https://yourself.mees.sh YOURSELF_CLIENT_ID=app_… YOURSELF_CLIENT_SECRET=ysec_… (shown once when the app was created; rotate it if lost) YOURSELF_REDIRECT_URI=http://localhost:5173/auth/callbackAdd the helper
One file, one dependency (
jose). It does PKCE, state and nonce checks, ID token verification, and a signed session cookie.shnpm install jose curl -fsSL https://yourself.mees.sh/sdk/yourself-auth.ts -o app/yourself-auth.server.tsConfigure it
app/auth.server.tsimport { redirect } from "react-router"; import { createYourselfAuth } from "./yourself-auth.server"; export const auth = createYourselfAuth({ issuer: process.env.YOURSELF_ISSUER!, clientId: process.env.YOURSELF_CLIENT_ID!, clientSecret: process.env.YOURSELF_CLIENT_SECRET!, redirectUri: process.env.YOURSELF_REDIRECT_URI!, }); export async function requireUser(request: Request) { const user = await auth.getUser(request); if (!user) { const url = new URL(request.url); throw redirect(`/auth/login?return_to=${encodeURIComponent(url.pathname + url.search)}`); } return user; }Routes
Register them in
app/routes.ts:route("auth/:action", "routes/auth.ts").app/routes/auth.tsimport { auth } from "../auth.server"; import type { Route } from "./+types/auth"; export function loader({ request, params }: Route.LoaderArgs) { if (params.action === "login") return auth.signIn(request); if (params.action === "callback") return auth.handleCallback(request); throw new Response("Not found", { status: 404 }); } export function action({ params }: Route.ActionArgs) { if (params.action === "logout") return auth.signOut(); throw new Response("Not found", { status: 404 }); }Protect pages
Call
requireUserin the loader of any route (or a layout route that wraps them all).tsexport async function loader({ request }: Route.LoaderArgs) { const user = await requireUser(request); return { user }; }Check it works
Start the app and open it. You're sent to yourself, sign in with your passkey, and land back in the app signed in. The
list_activityMCP tool (or the dashboard) shows anapp.signed_inevent.