Loaders & actions
Protect a route by calling requireUser() in its loader, and run logins from an action. Auth lives on the server, right where your data does.
- requireUser() in loaders
- Logins from actions
Remix
Add login and route protection with the primitives Remix already gives you: loaders, actions, and cookie sessions. Authdog slots into the web-fundamentals model instead of replacing it.
Guard a loader
// app/routes/dashboard.tsx
import { requireUser } from "@authdog/remix"
export async function loader({ request }) {
const user = await requireUser(request)
return json({ user })
}
Log in with an action
// app/routes/login.tsx
import { authenticator } from "@authdog/remix"
export async function action({ request }) {
return authenticator.login(request, {
successRedirect: "/dashboard",
})
}
Web fundamentals, not magic
Auth that works with loaders, actions, and progressive enhancement, just as the framework was designed.
Protect a route by calling requireUser() in its loader, and run logins from an action. Auth lives on the server, right where your data does.
Sessions ride Remix's own cookie session storage with secure, signed, HTTP-only cookies, so there is no extra client state to manage.
Enforce auth at any level of your nested route tree. Parent loaders gate whole sections while child routes inherit the verified user.
Login and logout work as plain HTML form posts, so they keep working before JavaScript loads, exactly the way Remix intends.
Tokens are refreshed transparently inside your loaders. Expired sessions renew without an extra round trip you have to write.
A fully typed SDK gives you autocomplete for the user, claims, and roles returned to your loaders and actions.
Add @authdog/remix-node and your environment keys.
Point the SDK at your Remix cookie session storage, once.
Call requireUser(request) in the loaders you protect.
Install the SDK, wire up your session storage, and protect your loaders today. Free to start, with secure defaults built in.