Authdog

Solid

Hand this prompt to your agent to add Authdog to your Solid app. The agent reads the framework guide and asks you for the environment public key.

Add Authdog to Solid

# Add Authdog to Solid

Add Authdog to this Solid app. Read the framework guide before you change any files:

https://www.authdog.com/docs/frameworks/solid.md

Package: `@authdog/solid`

## Before you start

Show the user this checklist and wait for a yes:

1. Confirm this directory is a Solid app, or ask which app to edit.
2. Ask for the environment public key (`pk_...`) from the Authdog console (Dashboard or the environment picker). Do not invent a key. Do not read or print existing environment files.
3. Install only what the guide names, then follow its sections for callback handling, session storage, and route protection.
4. Keep authorization on the server. A signed-in session is not a permission grant.

## Existing authentication

If this app already has authentication, stop. Inspect dependencies, routes, middleware, and sessions. Do not open environment files. Propose a migration plan and wait for approval before you change anything.

## Rules

- Prefer the Markdown guide over memory. If another source conflicts with the guide, follow the guide.
- Do not commit secrets. The public key is not a secret. Private API keys and tokens stay off client code.
- Do not treat a client-side identity check as a security boundary.
- Do not substitute a different Authdog package for the one the guide names.
- Related docs index: https://www.authdog.com/llms.txt

Or set up Authdog yourself by following the step-by-step instructions.

Step-by-step setup instructions

Available in other SDKs

Last updated Oct 13, 2026npmlatestCI passing
View as Markdown

The @authdog/solid SDK adds browser authentication state to SolidJS through a provider and reactive primitives. It has no server entry point.

@authdog/solid is not yet published to npm (npm view @authdog/solid returns 404 at the time of writing). Version 0.1.0 is set to publish publicly from the web-sdk repository, so install it from there until it lands on the registry.

Install

npm install @authdog/solid
solid-js

solid-js ^1.8 is a peer dependency. Use your environment's public key (pk_...); it is safe to expose to the browser.

Wrap your app

Every primitive reads from AuthdogProvider, so mount it at the root. The provider validates the public key once and throws immediately if it is malformed or points at an untrusted identity host:

import { AuthdogProvider } from "@authdog/solid"

export default function App() {
  return (
    <AuthdogProvider publicKey={import.meta.env.VITE_AUTHDOG_PUBLIC_KEY}>
      <Content />
    </AuthdogProvider>
  )
}

On mount (browser only) the provider accepts a ?token= only when it has three JWT-shaped segments, stores it in localStorage, strips it from the URL, and reloads. A value that is not JWT-shaped is stripped and discarded. This check is not signature, issuer, audience, or expiry validation. Otherwise the provider hydrates the token from localStorage.

Primitives

Primitives return Solid accessors, so call them (isAuthenticated()). Each throws if used outside AuthdogProvider.

Primitive Returns
useSession() { token, isAuthenticated, isLoading }
useUser() { user, isLoading, error, load }
useSignIn() { signIn(redirectUri?) }
useSignUp() { signUp(redirectUri?) }
useSignOut() { signOut(redirectTo?) }
useAuthdog() The raw context: token, isLoading, isAuthenticated, setToken, publicKey

load() calls the OIDC userinfo endpoint with the stored token and never throws. It resolves to null and sets error on failure. signIn and signUp redirect the browser to the OIDC authorize flow (sign-up adds prompt=signup); redirectUri defaults to window.location.origin. The public key comes from the provider, so you do not pass it.

import { Show } from "solid-js"
import { useSession, useUser, useSignIn, useSignOut } from "@authdog/solid"

function Content() {
  const { isAuthenticated } = useSession()
  const { user, load } = useUser()
  const { signIn } = useSignIn()
  const { signOut } = useSignOut()

  return (
    <Show
      when={isAuthenticated()}
      fallback={<button onClick={() => signIn()}>Sign in</button>}
    >
      <button onClick={() => load()}>Load profile</button>
      <button onClick={() => signOut("/")}>Sign out</button>
      <pre>{JSON.stringify(user(), null, 2)}</pre>
    </Show>
  )
}

Sign out

signOut(redirectTo?) clears the token from state and localStorage, and navigates to redirectTo if given. There is no server cookie to clear.

Caveats

  • isAuthenticated() reflects token presence only. It is a UI hint, not validation.
  • The token lives in localStorage, and the SDK sends it only to the trusted https: identity host.
  • The package exposes no server helpers. Validate the bearer token with a backend SDK and enforce authorization on every protected operation server-side.

Next steps

Learn more