omg Docs
SDK

Multi-user auth

Platform sign-in and per-user data for published omg apps.

Every app published from make.omg.dev uses platform sign-in. Visitors sign in on make.omg.dev, then receive a separate app-bound identity. The runtime verifies signed app JWTs, the SDK attaches them automatically, and .scoped("user") collections filter rows by _owner server-side. You don't run a backend, you don't register an OAuth client, and you don't write a token endpoint.

TL;DR

// schema.ts — mark a collection user-scoped
import { defineSchema, collection, fields } from "@omg-dev/schema"

export default defineSchema({
  collections: {
    notes: collection({
      fields: { title: fields.string(), body: fields.string() },
    }).scoped("user"),
  },
})
// src/App.tsx — gate the UI on login
import { VibesAuthProvider, VibesAuthGuard, useUser } from "@omg-dev/sdk"
import { useQuery } from "@omg-dev/sdk"

interface Note { id: string; title: string; body: string; _owner: string }

function Notes() {
  const user = useUser()
  const { data, create } = useQuery<Note>({ api: "/api/notes", collection: "notes" })
  return (
    <>
      <p>Hello, {user?.email}</p>
      <button onClick={() => create({ title: "hi", body: "" })}>Add</button>
      <ul>{data.map(n => <li key={n.id}>{n.title}</li>)}</ul>
    </>
  )
}

export default function App() {
  return (
    <VibesAuthProvider>
      <VibesAuthGuard>
        <Notes />
      </VibesAuthGuard>
    </VibesAuthProvider>
  )
}

That's it. Two users hitting the same deploy each see only their own notes rows.

How it fits together

LayerWhat happens
schema.ts.scoped("user") adds an _owner column and tells the runtime to filter on it.
<VibesAuthProvider>Mounts the auth context, reads the platform app identity, and resolves the app-scoped JWT after hosted sign-in.
useCollection()Reads the JWT from the auth context and attaches Authorization: Bearer <jwt> to every fetch.
@omg-dev/serverVerifies the app JWT using the platform issuer and JWKS, seeds ctxStore.userId, and filters scoped tables by _owner.

Publishing registers the app with the platform. App code needs no separate auth registration.

Marking a collection user-scoped

collection({ fields: { … } }).scoped("user")

The runtime adds a hidden _owner: string column at migration time. On POST /api/<collection> the handler stamps _owner = ctx.userId; on GET, PATCH, and DELETE it filters by _owner = ctx.userId. A request with no JWT to a scoped collection returns 401. A PATCH or GET /:id for another user's row returns 404 (we treat "not yours" and "doesn't exist" identically — anything else leaks row existence).

For shared/global apps, omit .scoped("user"). Every signed-in user can read and mutate every row. Optionally stamp authorship from the client:

const user = useUser()
await create({ title: "hi", author: user?.name })

Login UI

Apps set to omg.dev login in project settings are already gated by the platform before their UI loads. <VibesAuthProvider> reuses that identity, so <VibesAuthGuard> does not show a second login form. Keep the guard in the app: the same code still works if the app is later made public, where visitors may need to sign in for private, user-scoped features.

<VibesAuthGuard> renders <VibesLogin> when no user is signed in. On a deployed app it is one Sign in with omg.dev button. The button opens the hosted sign-in page at https://make.omg.dev/access?return=<current URL>. That page offers email code, passkey, Google, and Apple. After sign-in it sends the visitor back to the same page, and useUser() returns the user.

App code does not collect email codes, passwords, passkeys, or magic links. Use useAuth().signIn() or <VibesLogin> to start platform sign-in. The platform validates the app return URL and redeems a one-time code for that app. Preview uses the verified creator identity. Localhost has no app-access return registration; check sign-in on a published app that you own.

The card reads the host app's shadcn semantic tokens (--card, --foreground, --muted-foreground, …), so it matches the app's theme. The button keeps the omg.dev brand color.

Quick start — bundled <VibesLogin>Live demo

Sign in to continue

Use your omg.dev account to save your plans.

Secure sign-in by omg.dev

Want a polished version composed from real shadcn primitives? Install the vibes-login block from the omg.dev registry:

bunx shadcn@latest add https://docs.omg.dev/r/vibes-login.json

That writes components/auth/vibes-login.tsx into your project, pulls in button and card, and adds @omg-dev/sdk to your dependencies. It calls the same platform sign-in method. Pass it to the guard via fallback:

import { VibesAuthGuard } from "@omg-dev/sdk"
import { VibesLogin } from "@/components/auth/vibes-login"

<VibesAuthGuard fallback={<VibesLogin />}>
  <App />
</VibesAuthGuard>
After installing via shadcn addLive demo

Sign in to continue

Secure sign-in by omg.dev

For a custom landing page, keep one platform sign-in button:

const { signIn } = useAuth()
return <button onClick={signIn}>Sign in with omg.dev</button>

Use the platform method for every sign-in button. Do not add an app-owned sign-in form, auth provider, session store, or direct auth bridge request.

Hooks

useUser(): VibesUser | null
useAuth(): {
  user: VibesUser | null
  loading: boolean
  token: string | null            // the JWT, for custom fetch
  signOut(): Promise<void>
  signIn(): void                // opens make.omg.dev/access
}

interface VibesUser { id: string; email: string; name?: string }

useUser is the friendly read-only hook; useAuth is the full surface.

What you DON'T need to do

  • <VibesAuthProvider> reads the app identity injected by the platform. App code needs no appId configuration.
  • App hosts stay outside the platform trusted-origin list. Sign-in uses the hosted app-access flow, and app tokens use the same-origin platform bridge.
  • No JWT plumbing — useCollection reads the token from context and attaches it to every request. Custom fetch to your own functions/<name>.ts? Pull token off useAuth() and add the header yourself, or call vibesFetch(client).
  • The published runtime verifies app tokens. App code needs no separate auth backend.

Local dev

Localhost has no published app identity or registered app-access return host.

Use the make preview for the verified creator identity. Check the full visitor sign-in flow on a published app that you own. Keep local fixtures separate from production identities. Do not add a local sign-in form or weaken collection permissions to test authentication.