-
Notifications
You must be signed in to change notification settings - Fork 29
Description
If anyone has taken the time to maintain one for Next.js and/or Hono examples please consider contributing it
Next.js (maybe some applies to Hono)
Here's some starter content I've been using with moderate success:
-
If you need to modify the schema, do not modify the
auth.schema.tsfile directly! You must modify the plugins schema (use context7 to look into better-auth plugins, schema, adapters, endpoints, and more if you're at all unsure.) If no schema applies, you need to create a new plugin. -
After modifying schema, run
pnpm run auth:update. if that passes runpnpm run db:generateand then check drizzle/. If it looks okay runpnpm run db:migrate:prod. Lastly, add to seed data and runpnpm run db:seed. -
When making front end components that need data, do not make direct fetch calls, use the auto-inferred type-safe
authClientcalls. See other components for examples of this. -
When making better-auth plugin endpoints, we do not permit query or path params. Must be POST requests with zod for body schema declaration/validation. If you have no params at all, then use GET requests and call
authClient.something.list()instead ofauthClient.something.list({}). -
New schemas and endpoints must be added as better-auth plugins. Do research on existing plugins we have and with context7 so you get it just right (type system of it is a bit delicate). If there are no related schema or endpoints yet, you need to create a new plugin.
-
The Better Auth type inference system automatically removes certain prefixes and converts the endpoint names. So
getDatasheetTypesbecomestypes, and the HTTP method and other details are inferred. Please study the existing plugins and corresponding authClient calls in other files and frontend components to understand this.