Web-side provider
Wrap AuthdogProvider around your app in web/src/App.tsx and session state is available across every page and cell.
- Pages and cells
- One-time setup
RedwoodJS
Add auth with a web-side React provider and api-side helpers for Redwood functions and services. Sessions use the same cookie and OIDC flow as every other Authdog SDK, so one environment spans both sides.
Web-side provider
// web/src/App.tsx
import { AuthdogProvider } from "@authdog/redwood/web"
const App = () => (
<AuthdogProvider>
<RedwoodProvider><Routes /></RedwoodProvider>
</AuthdogProvider>
)
Protect a Redwood function
// api/src/functions/me.ts
import { createAuthdog } from "@authdog/redwood/api"
const authdog = createAuthdog({ publicKey: process.env.PK_AUTHDOG! })
export const handler = authdog.requireAuth(async (event) => ({
statusCode: 200,
body: JSON.stringify(event.authdog.user),
}))
Web provider meets api helpers
A provider for the web side and typed helpers for the api side: session state in the UI, real enforcement in your functions and services.
Wrap AuthdogProvider around your app in web/src/App.tsx and session state is available across every page and cell.
createAuthdog() gives you getSession, getUser, requireAuth, and logout for Redwood functions and services.
requireAuth wraps your function handler and validates the session before it runs. This is the true enforcement point.
Inside a Redwood service, authdog.getUser(context.event) resolves the current user straight from the incoming request.
Uses the same authdog-session cookie and OIDC userinfo flow as every other @authdog/* package, so one environment spans web and api.
event.authdog.user is typed end to end on the api side, and the web-side hooks are typed for your components.
Add @authdog/redwood to the web and api sides.
Add AuthdogProvider in web/src/App.tsx.
Wrap api handlers in requireAuth.
Install the SDK on both sides, wrap your app, and protect your functions today. Free to start, with secure defaults built in.