Installation
signUp()
Create a new user account with email and password.Parameters
email(string, required) - User’s email addresspassword(string, required) - User’s passwordname(string, optional) - User’s display nameredirectTo(string, optional) - Used for link-based email verification. The email link always opens an InsForge backend endpoint first; after the token is verified, InsForge redirects the browser to this URL with the verification result. Required whenverifyEmailMethodis set tolink. This URL must be included inallowedRedirectUrls. Recommended: use your app’s sign-in page.
Returns
When
requireEmailVerification is true, accessToken will be null until the user verifies their email. InsForge sends a verification email with either a link or a 6-digit code, based on your dashboard configuration (verifyEmailMethod). For code verification, implement a page that prompts the user to enter the code (see verifyEmail()). For link verification, provide a redirectTo URL that should receive the browser after InsForge verifies the token. Recommended: use your sign-in page as redirectTo, then show a success message and ask the user to sign in with their email and password.Example
Output
signInWithPassword()
Sign in an existing user with email and password.Parameters
email(string, required) - User’s email addresspassword(string, required) - User’s password
Returns
Example
Output
signInWithOAuth()
Start OAuth authentication flow with configured providers (built-in providers like Google/GitHub, plus any custom provider key configured from the dashboard).Parameters
provider(string, required) - OAuth provider key (e.g.,google,github, or custom provider key likeokta-company)redirectTo(string, optional) - URL to redirect after authenticationskipBrowserRedirect(boolean, optional) - If true, returns OAuth URL without auto-redirecting (for mobile apps)
Returns
After OAuth redirect, SDK automatically detects the callback
insforge_code, exchanges it for a
session, and saves the session automatically.Example
Custom providers must be configured first in the InsForge dashboard under
Auth Methods with client credentials and an OIDC discovery URL.Output
signOut()
Sign out the current user and clear session.Parameters
NoneReturns
Example
Output
getCurrentUser()
Get the currently signed-in user. For browser apps, callauth.getCurrentUser() during startup. If a valid httpOnly refresh cookie is present, the SDK will refresh the session automatically before returning the user.
For server mode, call refreshSession({ refreshToken }) explicitly when you need to refresh an expired access token.
Parameters
NoneReturns
Example
Output
getProfile()
Get any user’s public profile by ID. Returns a flat profile object with all fields at the top level.Parameters
userId(string, required) - User ID to fetch profile for
Returns
Example
Output
setProfile()
Update current user’s profile in users table. Supports any dynamic fields and returns the updated profile as a flat object.Parameters
profile(object) - A key-value map of profile fields to update. Any fields are accepted.
name(predefined, string) - User’s display nameavatar_url(predefined, string) - Profile picture URL
Returns
Example
Output
resendVerificationEmail()
Resend email verification when the previous OTP has expired or was not received. Uses the method configured in auth settings (verifyEmailMethod). When method is code, sends a 6-digit numeric code. When method is link, sends a browser verification link that goes through an InsForge backend endpoint first.
This endpoint prevents user enumeration by returning success even if the email doesn’t exist.
Parameters
email(string, required) - User’s email addressredirectTo(string, optional) - Used for link-based email verification. The email link always opens an InsForge backend endpoint first; after the token is verified, InsForge redirects the browser to this URL with the verification result. Required whenverifyEmailMethodis set tolink. This URL must be included inallowedRedirectUrls. Recommended: use your app’s sign-in page.
Returns
Example
Output
verifyEmail()
Verify an email address with a 6-digit code. For link-based verification, users should click the email link, which opensGET /api/auth/email/verify-link in the browser.
Successfully verified users who use this code endpoint will receive a session token.
For link-based verification, your frontend should handle the browser redirect like this:
- Success:
?insforge_status=success&insforge_type=verify_email - Error:
?insforge_status=error&insforge_type=verify_email&insforge_error=... insforge_status: Result of the browser link flow. For verification, values aresuccessorerror.insforge_type: Flow identifier. For verification links this is alwaysverify_email.insforge_error: Present only wheninsforge_status=error. Human-readable error message for display or logging.
redirectTo. When insforge_status=success, show a confirmation message and ask the user to sign in with their email and password.
Parameters
email(string, required) - User’s email addressotp(string, required) - 6-digit verification code
Returns
Example
Output
sendResetPasswordEmail()
Send password reset email using the method configured in auth settings (resetPasswordMethod). When method is code, sends a 6-digit numeric code for two-step flow. When method is link, sends a browser reset link that goes through an InsForge backend endpoint first.
This endpoint prevents user enumeration by returning success even if the email doesn’t exist.
Parameters
email(string, required) - User’s email addressredirectTo(string, optional) - Used for link-based password reset. The email link always opens an InsForge backend endpoint first; InsForge then redirects the browser to this URL with the resettokenin the query string so your app can render its own reset-password page. Required whenresetPasswordMethodis set tolink. This URL must be included inallowedRedirectUrls. Recommended: use your app’s dedicated reset-password page.
Returns
Example
Output
exchangeResetPasswordToken()
Exchange a 6-digit reset password code for a reset token. This is step 1 of the two-step password reset flow (only used whenresetPasswordMethod is code).
This endpoint is not used when
resetPasswordMethod is link, because the browser reset-link flow uses the emailed link token directly.Parameters
email(string, required) - User’s email addresscode(string, required) - 6-digit code from the email
Returns
Example
Output
resetPassword()
Reset user password with a token. The token can be:- Magic link token: Provided in the reset page URL from
sendResetPasswordEmailwhen method islink - Reset token: From
exchangeResetPasswordTokenafter code verification when method iscode
Parameters
newPassword(string, required) - New password for the userotp(string, required) - Reset token or magic link token
- Ready to reset:
?token=...&insforge_status=ready&insforge_type=reset_password - Error:
?insforge_status=error&insforge_type=reset_password&insforge_error=... token: Present only wheninsforge_status=ready. Pass this value toresetPassword({ otp }).insforge_status: Result of the browser link flow. For reset links, values arereadyorerror.insforge_type: Flow identifier. For reset links this is alwaysreset_password.insforge_error: Present only wheninsforge_status=error. Human-readable error message for display or logging.
insforge_status=ready and token is present.