Core Options
getDate
A function to generate the current date for invite operations.Custom date generator function.
invitationTokenExpiresIn
Number of seconds the invitation token remains valid.Token expiration time in seconds (default: 1 hour).
inviteCookieMaxAge
Maximum age for the invitation cookie in seconds. This controls how long users have to complete the login flow before activating the token if they are not logged in.Cookie max age in seconds (default: 10 minutes).
Permission Checks
canCreateInvite
A function or boolean that determines if a user can create an invite. Can also accept a Permissions object for integration with the admin plugin.Permission check for creating invites.
invitedUser: Object withemail?androlepropertiesinviterUser: The user creating the invite (UserWithRole)ctx: Generic endpoint context
canAcceptInvite
A function or boolean that runs before a user accepts an invite.Permission check for accepting invites.
invitedUser: The user accepting the invite (UserWithRole)newAccount: Boolean indicating if this is a new account
canCancelInvite
A function or boolean that runs before a user cancels an invite. Note: regardless of this option, only the user who created the invite can cancel it.Permission check for canceling invites.
inviterUser: The user who created the invite (UserWithRole)invitation: The invitation being canceled (InviteTypeWithId)ctx: Generic endpoint context
canRejectInvite
A function or boolean that runs before a user rejects an invite. Note: regardless of this option, only the invitee (user whose email matches the invite email for private invites) can reject it.Permission check for rejecting invites.
inviteeUser: The user rejecting the invite (UserWithRole)invitation: The invitation being rejected (InviteTypeWithId)ctx: Generic endpoint context
Token Configuration
defaultTokenType
The default token type for invitations.token: Generates a 24-character ID usinggenerateId(24)code: Generates a 6-character alphanumeric code usinggenerateRandomString(6, "0-9", "A-Z")custom: Uses thegenerateTokenoption (required)
generateToken
A custom function to generate invitation tokens. Required when usingdefaultTokenType: 'custom'.
Custom token generator function.
See Custom Tokens for detailed examples.
Redirect URLs
defaultRedirectToSignUp
The default URL to redirect users to sign up.Sign-up redirect URL.
defaultRedirectToSignIn
The default URL to redirect users to sign in.Sign-in redirect URL.
defaultRedirectAfterUpgrade
The default redirect URL after upgrading a role or logging in with an invite. Use{token} as a placeholder for the actual token.
Post-upgrade redirect URL with token placeholder.
defaultCustomInviteUrl
Custom URL format for invite links. Use{token} and {callbackUrl} as placeholders.
Custom invite URL template.
Default Behavior
defaultShareInviterName
Whether the inviter’s name should be shared with the invitee by default. When enabled, the person receiving the invitation will see the name of the user who created the invitation.Share inviter name with invitee.
defaultMaxUses
Maximum times an invite can be used.Maximum number of uses per invite.
defaultSenderResponse
How the sender should receive the token (only applies when no email is provided).Response format for invite creator.
defaultSenderResponseRedirect
Where to redirect the user by default (only if no email is provided).Default redirect destination.
Cleanup Options
cleanupInvitesOnDecision
Delete invitations when a decision is made (rejected, canceled).Auto-delete invites on rejection or cancellation.
cleanupInvitesAfterMaxUses
Delete invitations after they reach maximum uses.Auto-delete invites after max uses reached.
Email Notifications
sendUserInvitation
Send an email to the user with the invite link.Email notification handler for invitations.
data.email: Recipient email addressdata.name: Recipient name (optional)data.role: Role being assigneddata.url: Full invite URLdata.token: Invite tokendata.newAccount: Boolean indicating if this is a new accountrequest: Request object (optional)
Callbacks
onInvitationUsed
A callback function that is triggered when an invite is used.Callback executed after invite acceptance.
data.invitedUser: Original user before role update (UserWithRole)data.newUser: User after role update (UserWithRole)data.newAccount: Boolean indicating if this is a new accountrequest: Request object (optional)
Hooks
inviteHooks
Hooks for various invite lifecycle events.Lifecycle hooks for invite operations.
beforeCreateInvite
Runs before a user creates an invite.afterCreateInvite
Runs after a user creates an invite.beforeAcceptInvite
Runs before a user accepts an invite. You can return a user object to override the invited user.afterAcceptInvite
Runs after a user accepts an invite.beforeCancelInvite
Runs before a user cancels an invite.afterCancelInvite
Runs after a user cancels an invite.beforeRejectInvite
Runs before a user rejects an invite.afterRejectInvite
Runs after a user rejects an invite.Schema Customization
schema
Custom schema configuration for the invite plugin.Custom database schema configuration.
See Database Schema for complete schema reference.