Skip to content

fix(types): infer server user additionalFields in useSignUp - #836

Merged
vite-hub[bot] merged 4 commits into
mainfrom
fix/signup-additional-fields
Dec 4, 2026
Merged

vite-hub[bot] merged 4 commits into
mainfrom
fix/signup-additional-fields

Conversation

@onmax

@onmax onmax commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Fields from user.additionalFields in the server config are missing from useSignUp('email'). Passing one fails to typecheck with TS2353 ... does not exist in type, even though Better Auth stores it at runtime. AuthUser and updateUser already include those fields, and plugin fields such as username already show up in sign-up.

useSignUp takes its types from AppAuthClient, the return type of the client config. Better Auth only passes server additionalFields to the client when you add inferAdditionalFields<typeof auth>() to the client config, which means importing the server auth type into app code. The module already reads the server config for the user types, so sign-up should get those fields too.

This PR generates an AuthUserSignUpFields type from the server's input-enabled user.additionalFields, the same way AuthUserUpdateInput is built. useSignUp('email') adds it to the email input. The fields keep the required setting from the config, and fields with input: false stay out. AppAuthClient doesn't change. If the client config already declares a field, the client's type wins. In clientOnly mode the type is empty.

The plugins-type-inference fixture now has a required tenantCode. On main it fails with TS2353: 'tenantCode' does not exist, and it passes here. A missing required field and a readOnlyCode with input: false both fail to typecheck, as expected. The types project and pnpm typecheck pass. I didn't add a fixture for a client that already uses inferAdditionalFields().

Fixes #831

@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxt-better-auth-docs Ready Ready Preview Dec 4, 2026 9:32pm UTC

@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxtjs/better-auth@836

commit: 94abeb3

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
better-auth 94abeb3 Commit Preview URL

Branch Preview URL
Dec 04 2026, 09:32 PM

@vite-hub

vite-hub Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-12-04T21:09:12.632Z 5m 21s
View session Completed 2026-12-04T20:51:02.555Z 8m 35s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head.

Session

Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head.

Session

Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head.

Session

Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head.

Session

Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head.

View session

PR #836 is ready to merge. I verified that the prior fix makes Nitro 2 shared projects infer required and optional sign-up fields while excluding fields marked `input: false`. The review thread is resolved, Pullfrog found no new issues, and all reported hosted checks, five focused tests, and `pnpm lint` passed. No further changes were needed.

View session

Fixed the reported P1: Nitro 2 shared projects now infer required and optional sign-up fields without enabling other server augmentations. All four focused tests and `pnpm lint` passed. Pushed `75ab7b2`, resolved the review thread, and am waiting for hosted checks.

Session

Waiting for review checks before the next pass.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

This PR does not provide server additionalFields inference for all supported server config shapes.

Approach: sound in principle — the generated server type is the right source for the email sign-up overlay, but the new augmentation is not available in every TypeScript program that consumes the composable.

Reviewed changes The generated AuthUserSignUpFields augmentation, the useSignUp('email') type overlay, and the plugin type-inference fixture were reviewed.

  • Generated sign-up fields. Server user.additionalFields are converted with Better Auth's client-input inference, preserving requiredness and excluding input: false fields.
  • Email sign-up typing. Only the email method is extended, and Omit<..., keyof Data> preserves fields already declared by the client method.
  • Regression coverage. The fixture checks required tenantCode, optional internalCode, and rejection of readOnlyCode.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-luna(high) | 𝕏

Comment thread src/module/type-templates.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound — the new commits separate sign-up field inference from the guarded server-only templates, allowing unsafe Nitro 2 configurations to expose the shared contract without sharing the rest of the server config graph.

Reviewed changes The incremental changes since the prior Pullfrog review were reviewed, including the shared-template registration and Nitro 2 alias fixture.

  • Separated shared sign-up inference. Registered AuthUserSignUpFields independently in the shared type program while keeping the broader server inference templates behind their existing safety gate.
  • Added unsafe-config coverage. Added a #server and db dependent Nitro 2 fixture that checks required and optional fields and rejects input: false fields.

Pullfrog  | View workflow run | Using gpt-5.6-luna(high) | 𝕏

@vite-hub
vite-hub Bot merged commit 0c66e99 into main Dec 4, 2026
13 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 4, 2026

This branch was successfully deployed

1 active deployment
Preview — 94abeb36 Deployed Dec 4, 2026 by vercel[bot]
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.

The useSignUp composable is missing user additionalFields support

1 participant