Repository navigation
v0.3.0
v0.3.0
⚠️ Breaking Changes
- redeem:
nameis now required to redeem a sign-up invitation.invite.redeemand gn-up redemptions that omit it with the newNAME_REQUIRED(400) error; the accept flowexists to populate the invitee's profile, and a nameless profile defeats it. Creating an invite still does not require a name, and activation flows (open mode, or invites held by existing accounts) are
unaffected. - api:
requiredFieldsfromGET /invite/getnow includes"name"for everySIGN_UPresponse. Pages that render inputs directly fromrequiredFieldspick this up automatically; tests asserting
the exact array need updating.
🚀 Enhancements
-
options: New
additionalFieldsoption collects extra profile fields at redemption,h'suser.additionalFields:type(string|number|boolean|date),required(defaulttrue),defaultValue, an optional standard-schemavalidator(a plain zod schema works), andactions. Fields become nullable columns on the user model (runmigrate/generate; do not
duplicate them underuser.additionalFields), are validated before the invite use is conREQUIRED/ADDITIONAL_FIELD_INVALID`, so a rejected submission never burns a use), andare stored on the created or activated user.betterEnrollment({ additionalFields: { department: { type: "string" }, referral: { type: "string", required: false }, seniority: { type: "number", validator: { input: z.number().min(0) } }, team: { type: "string", actions: ["SIGN_UP", "CONFIRM"] } } });
-
redeem: Per-step collection via actions. Of the four next actions, SIGN_IN and the terminal state render no fields; SIGN_UP and CONFIRM are forms and can carry additional fields. The actions list
(default ["SIGN_UP"]) is exact, never additive: ["CONFIRM"] means confirm only; name both forms. On CONFIRM the values are written to the existing user in the same update as therole merge, and defaultValue is never applied there, so an absent field can never overwrite data the user already has. -
api: GET /invite/get now describes the current step's form: new optionalFields array an ({ [name]: { type, required } }) alongside requiredFields, computed per step: sign-upbuilt-ins plus that step's extra fields for SIGN_UP, the confirm-step fields for CONFIRM, and all three empty for SIGN_IN and terminal states.
📝 Migration Notes
- Add a name input to your invite page for SIGN_UP states (rendering from requiredFields does it by itself) and pass name in invite.redeem / invite.accept calls.
- If you adopt additionalFields, run npx @better-auth/cli migrate (or generate) to creatages that render from requiredFields / optionalFields pick the fields up automatically,CONFIRM included.