Sections
Theme

Configure & identity

configure, identify, reset, and setNotificationPreferences; push-token registration coming soon — initializing the SDK and managing the current user

Every integration starts here: configure initializes the SDK with your publishable key, identify attaches your user ID once someone signs up, and reset clears the identity on logout. The SDK is anonymous-first — everything works before identify is ever called, and the anonymous history merges when it is.

Pick your platform once — every code sample in the reference follows it.

configure

Initializes the SDK. Call once, as early as possible in your app's lifecycle — before any other Invitebase call. Generates (or restores) the anonymous ID from platform storage and, by default, starts inbound referral resolution.

ParameterTypeDescription
publishableKeystringYour publishable key (pk_test_… or pk_live_…). The prefix determines test vs live mode.
autoResolvebooleanRun inbound attribution automatically. Default true. Set false to control the moment yourself with resolveReferral().
debugLoggingbooleanLog SDK activity (named debug on Web and React Native). Default false.
invitebase.configure(publishableKey: string, options?: ConfigureOptions): void
lib/invitebase.ts
import invitebase from '@invitebase/js';

invitebase.configure(process.env.NEXT_PUBLIC_INVITEBASE_PUBLISHABLE_KEY, { debug: true });

export default invitebase;

Restores the anonymous ID from localStorage and immediately checks the current URL and stored cookie for an inbound referral code.

identify

Attaches your user ID to the current person and merges their anonymous history — attribution, events, and gate progress recorded before login all carry over. Idempotent: identifying the same user twice is a no-op, and every ordering of attribute → events → identify merges correctly. See Users & identity.

ParameterTypeDescription
user.idstringRequired. Your stable ID for this user.
user.emailstringOptional. Used for self-referral and disposable-email fraud checks.
user.namestringOptional. Privacy-safe display name shown to invitees ("You were invited by Alex").
user.traitsmapOptional. Arbitrary properties.
invitebase.identify(user: InvitebaseUser): Promise<void>
await invitebase.identify({
  id: 'usr_123',
  email: 'dana@example.com',
  name: 'Dana',
});

Throws an SDK error on failure.

reset

Clears the current identity (and any stored referral code) and starts a fresh anonymous session. Call on logout.

invitebase.reset(): void

No parameters.

setPushToken

Coming soon on all five SDKs. Push notifications and push-token registration are outside the November 15 release. No push-token setup is required for launch.

setNotificationPreferences

Sets the current user's referral-notification preferences — whether Invitebase may email or push them about referral activity (triggers). Email defaults to on. Push delivery is coming soon. Preferences are stored server-side per user, checked before every dispatch, and survive re-identification and new devices. Set for an anonymous user, they merge onto the identified user like everything else.

ParameterTypeDescription
preferences.emailbooleanAllow referral emails. Default true.
preferences.pushbooleanComing soon; push delivery is outside the November 15 release.

Omitted channels are left unchanged, so a single toggle can flip one channel without touching the other.

invitebase.setNotificationPreferences(preferences: NotificationPreferences): Promise<void>
await invitebase.setNotificationPreferences({ email: false });

Throws an SDK error on failure. The same preferences are settable server-side via POST /v1/referrers.

What's next

On this page