Add documentation for customizing the table name for jwks #1205

Closed
opened 2026-03-13 08:28:06 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @michaelhays on GitHub (May 14, 2025).

Update

It is possible to customize the name of the jwks table -- see https://github.com/better-auth/better-auth/issues/2659#issuecomment-2938631725.

It would be great if this were documented at https://www.better-auth.com/docs/plugins/jwt#jwks.

Original Post

It does not appear that the jwks table name is able to be customized: https://www.better-auth.com/docs/plugins/jwt#jwks

It would be great if we could do this the same way that we can for the core tables: https://www.better-auth.com/docs/concepts/database#custom-table-names

I've tried patching the model fields in this file, but ran into some other issues around getting the model name from the schema.

(Sidenote: the table name jwks is plural, while most others are singular, e.g. user)

Originally created by @michaelhays on GitHub (May 14, 2025). ## Update It _is_ possible to customize the name of the `jwks` table -- see https://github.com/better-auth/better-auth/issues/2659#issuecomment-2938631725. It would be great if this were documented at https://www.better-auth.com/docs/plugins/jwt#jwks. ## Original Post It does not appear that the `jwks` table name is able to be customized: https://www.better-auth.com/docs/plugins/jwt#jwks It would be great if we could do this the same way that we can for the core tables: https://www.better-auth.com/docs/concepts/database#custom-table-names I've tried patching the `model` fields in [this file](https://github.com/better-auth/better-auth/blob/e9bc7fcf7e247796a39007aceae9f00d15d6350e/packages/better-auth/src/plugins/jwt/adapter.ts), but ran into some other issues around getting the model name from the schema. (Sidenote: the table name `jwks` is plural, while most others are singular, e.g. `user`)
Author
Owner

@JoshB2chE commented on GitHub (Jun 4, 2025):

Hey @michaelhays, it's a little confusing but this is the way I've found that works. Also, you can change the field names here too. Not sure why the docs don't mention adding the schema via the jwt() function.

plugins: [
  jwt({
    schema: {
      jwks: { 
        modelName: 'jwks',
        fields: { ... }
      }
    }
  }),
]
...

Seems to be the intended way. Saw it on another plugin somewhere...

Best of luck!

@JoshB2chE commented on GitHub (Jun 4, 2025): Hey @michaelhays, it's a little confusing but this is the way I've found that works. Also, you can change the field names here too. Not sure why the docs don't mention adding the schema via the `jwt()` function. ```TypeScript plugins: [ jwt({ schema: { jwks: { modelName: 'jwks', fields: { ... } } } }), ] ... ``` Seems to be the intended way. Saw it on another plugin somewhere... Best of luck!
Author
Owner

@michaelhays commented on GitHub (Jun 4, 2025):

Thanks so much @JoshB2chE, worked like a charm! I tried looking everywhere internally for this config, but couldn't find it 😅

I'll update this issue to ask for better documentation around this.

@michaelhays commented on GitHub (Jun 4, 2025): Thanks so much @JoshB2chE, worked like a charm! I tried looking everywhere internally for this config, but couldn't find it 😅 I'll update this issue to ask for better documentation around this.
Author
Owner

@JoshB2chE commented on GitHub (Jun 4, 2025):

No worries! Yeah I can't remember where I saw it. Tried looking for the page again.

Cheers, JB

@JoshB2chE commented on GitHub (Jun 4, 2025): No worries! Yeah I can't remember where I saw it. Tried looking for the page again. Cheers, JB
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1205