#10321·better-auth

Use remote JWT signing with session cookie cache (jwt-plugin signingKey + custom sign)

Author: edenshaulCreated Jul 6, 2026Updated Sep 29, 2026
Labelscore

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

Hello! I want to use the jwt plugin with remote sign. We use an upstream IdP that identifies users, and we will use better-auth bff to manage the users, organizations, admin impersonation, mcp, etc. We don't want to own the jwks and don't want to have secrets and keys under our responsibility. We can use https://better-auth.com/docs/beta/plugins/jwt#custom-signing , and here we will call our IdP to get JWT based on the user data. We want to use session cookie caching as well, and in 1.7.0 there's https://better-auth.com/docs/beta/concepts/session-management#jwks-backed-cookie-cache-jwts new feature, which enables to encrypt the session_data cookie with the custom jwt plugin signing.

This works only when jwt({ jwt: { sign } }) is not implemented, hence there's no option to do remote sign with session cookie cache, only self sign. So we cannot use the jwt plugin https://better-auth.com/docs/beta/plugins/jwt#remote-signing , and also use cookie cache with the same signing key.

We've tried 1.7.0 because it enables to use custom jwt plugin on the session cookie cache, but not with custom signing.

So we want to use both jwt plugin with custom remote signing, and session cookie cache with the same signer, to not have 2 different signed jwts.

We also want to use stateless session management, because we don't want to persist secret data on our db currently. This must use cookie cache to do it, and we don't want to use and manager signing secret (so don't want to use compact).

Describe the solution you'd like

Possibility to use session cookie cache with jwt strategy, with jwt-plugin signing key.

Describe alternatives you've considered

We've considered managing our own signing secrets, but we don't want it under our responsibility. Also we can have a BETTER_AUTH_SECRET configured and use compact strategy, then we don't have 2 different jwt signers, but a compact token and a remote signed jwt. But we really want to avoid holding key and rotating it (even with the new versioned BETTER_AUTH_SECRETS), and we would opt to use the upstream IdP.

Additional context

No response