5-minute quickstart

Add sign-in to your app

1. Create a service

In the dashboard, create a service: a name, and the app URL your users come back to after signing in. The service gets a sign-in address on MyLogin.world; paste it below and every snippet on this page uses it.

Shown on the service page in the dashboard.

2. Install

npm install @mylogin/sdk

3. Add the middleware

Express
import { createAuth } from '@mylogin/sdk';

export const auth = createAuth({
  relayUrl: 'https://myapp-yourname.login.mylogin.world.compas.cs.stonybrook.edu',
  providers: { google: { mode: 'managed' } },
  // your service decides who gets in; return null to refuse
  onIdentity: (identity) => ({ sub: identity.sub, email: identity.email })
});

import express from 'express';
import { expressAuth } from '@mylogin/sdk/express';

const app = express();
const guard = expressAuth(auth);
app.use(guard.routes());          // /auth/login, /auth/status, /auth/me, /auth/logout
app.use(guard.loadUser());
app.get('/', guard.requireUser(), (req, res) => res.send(`hello ${req.user?.email ?? 'there'}`));
app.listen(3000);

onIdentity receives the verified identity and returns what you keep on your own session; return nothing to refuse the person. The middleware serves /auth/login, /auth/status, /auth/me and /auth/logout. Adapters for Fastify, Hono, and SvelteKit ship in the same package; the core works with any framework that uses Web Request and Response.

4. Providers

Managed mode needs nothing registered: our client is used and the result comes back to your app. For your own client, register this redirect URI with the provider and keep the client ID and secret in your app:

https://myapp-yourname.login.mylogin.world.compas.cs.stonybrook.edu/oauth/cb

5. Passkeys, when you want them

Pass a credential store to the middleware. Your app keeps the public keys and verifies each signature; our page runs the ceremony on your sign-in address.

6. Test

Open /auth/login. You are sent to your sign-in address, sign in, and land back on your app URL. If anything fails, run the check:

npx @mylogin/sdk doctor --relay https://myapp-yourname.login.mylogin.world.compas.cs.stonybrook.edu

Using an AI coding agent?

Paste this into Claude Code, Cursor, ChatGPT or similar.

Copy instructions
Add MyLogin.world sign-in to this app. Read https://mylogin.world.compas.cs.stonybrook.edu/llms.txt first and follow it. The sign-in address for this service is https://myapp-yourname.login.mylogin.world.compas.cs.stonybrook.edu. The app URL for the service must be set in the MyLogin.world dashboard to where this app runs.