Hookfish does not authenticate your users. Keep Auth.js, Clerk, Auth0,
Supabase Auth, or your existing session system in your application. After your
application authorizes a request, call Hookfish from the server with a scoped
broker credential.
This keeps application sessions out of Hookfish and broker credentials out of
the browser.
Protect an application route
Use your auth provider’s server middleware before the route handler. Retain the
user and tenant identifiers your authorization policy needs.
Keep provider-specific session verification inside authenticateRequest. Test
signed-in, signed-out, expired-session, and wrong-tenant cases.
Call Hookfish after authorization
Create the Hookfish Hono RPC client inside trusted server code. Select a broker
token whose resource scope matches the current user or organization.
Use the same pattern to start authorization, disconnect an account, retrieve a
provider token, or access a vault secret. Return only the data the browser
needs. Provider tokens and decrypted secrets should remain in server code.
Expose your application API to the browser
Export your application route type and create a separate Hono RPC client in
the browser. That client sends the user’s normal application session. It does
not send a Hookfish credential.
Never return a root key or scoped broker token to the browser. Application
authentication does not replace Hookfish resource scopes; enforce both.