Skip to content

Comments

Add an example to showcase how to setup authentication with better-auth.#948

Open
Muhammad-Bin-Ali wants to merge 8 commits intomainfrom
example/auth-agent
Open

Add an example to showcase how to setup authentication with better-auth.#948
Muhammad-Bin-Ali wants to merge 8 commits intomainfrom
example/auth-agent

Conversation

@Muhammad-Bin-Ali
Copy link
Contributor

Add examples/auth-agent — better-auth + JWT authentication for Agents

New example demonstrating how to secure a Cloudflare Agents server with better-auth, JWT authentication, and Cloudflare D1.

  • Cookie-based session auth for the browser, JWT via query param for WebSocket connections
  • JWT verification reads JWKS directly from D1 using jose's createLocalJWKSet (avoids Worker self-request)
  • onBeforeConnect and onBeforeRequest middleware protect agent WebSocket and HTTP routes
  • Full React UI with sign-up/sign-in and authenticated chat, styled with Kumo
  • Comprehensive README documenting architecture, auth flow, and design decisions with rationale

Generated by OpenCode

@Muhammad-Bin-Ali Muhammad-Bin-Ali self-assigned this Feb 19, 2026
@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

⚠️ No Changeset found

Latest commit: ae39d9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@948
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/ai-chat@948
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/codemode@948
npm i https://pkg.pr.new/cloudflare/agents/hono-agents@948

commit: 6a9e81e

@Muhammad-Bin-Ali Muhammad-Bin-Ali requested a review from a team February 20, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant