Embedding in your app
The screens are not hosted by ownauth. You install them into your app from its registry, like any other shadcn component, and they talk to your instance over the API.
1. Tell the components where ownauth is
Section titled “1. Tell the components where ownauth is”Before any client bundle runs:
<script>window.__OWNAUTH_URL__ = "https://auth.example.com";</script>Resolution order inside the components:
createOwnAuthClient(url)— explicitglobalThis.__OWNAUTH_URL__— set by your page, as aboveimport.meta.env.VITE_OWNAUTH_URL— Vite, Astro, Nuxt, SvelteKit- the current origin — correct only when ownauth serves its own preview UI
2. Install the screens you want
Section titled “2. Install the screens you want”npx shadcn@latest add https://auth.example.com/r/sign-in.jsonnpx shadcn@latest add https://auth.example.com/r/sign-up.jsonnpx shadcn@latest add https://auth.example.com/r/user-profile.jsonEach item is source code: it lands in components/auth/ and is yours to edit. No SDK version to
track, no component you cannot change.
The registry is also mirrored at https://ownauth.tariqjandaly.com/r/<name>.json if you want to try
an install before running your own instance.
3. Allow your origin
Section titled “3. Allow your origin”TRUSTED_ORIGINS=https://app.example.comExact match. CORS reflects only listed origins, with credentials allowed on those and no CORS headers at all on others.
4. Verify the session on the server
Section titled “4. Verify the session on the server”Never trust a client-side session context for authorization. Ask ownauth:
const cookieHeader = (await cookies()).getAll() .map((c) => `${c.name}=${c.value}`).join("; ");
const response = await fetch(`${process.env.OWNAUTH_URL}/api/auth/get-session`, { headers: { cookie: cookieHeader }, cache: "no-store",});const user = (await response.json())?.user ?? null;if (!user) redirect("/");That has a useful property: a ban, a revoked session, or a deleted account takes effect on the next request, because the answer is never cached.
The cookie rule that decides your domain layout
Section titled “The cookie rule that decides your domain layout”Install ownauth on a subdomain of the same registrable domain as your app:
| Layout | Cookie | Works? |
|---|---|---|
app.example.com ↔ auth.example.com |
first-party, shared via domain=.example.com |
yes |
example.com/app ↔ auth.example.com |
first-party | yes |
app.example.com ↔ auth.other-domain.com |
third-party | no — browsers block it |
No configuration fixes the third row. The instance’s own console states this: Security shows which origins share the cookie and which cannot.
A working example
Section titled “A working example”examples/next-app in the repository is a complete customer app: a registry-installed sign-in form
and a /protected page that verifies the session server-side.