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.
| Parameter | Type | Description |
|---|---|---|
publishableKey | string | Your publishable key (pk_test_… or pk_live_…). The prefix determines test vs live mode. |
autoResolve | boolean | Run inbound attribution automatically. Default true. Set false to control the moment yourself with resolveReferral(). |
debugLogging | boolean | Log SDK activity (named debug on Web and React Native). Default false. |
invitebase.configure(publishableKey: string, options?: ConfigureOptions): voidimport 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.
Invitebase.configure(publishableKey: String, options: InvitebaseOptions? = nil)@main
struct MycompanyApp: App {
init() {
Invitebase.configure(publishableKey: "pk_test_51Hq2jK")
}
// …
}Restores the anonymous ID from the Keychain and schedules clipboard-handoff resolution for first launch. UIKit wiring in iOS setup.
Invitebase.configure(context: Context, publishableKey: String, options: InvitebaseOptions? = null)class MycompanyApplication : Application() {
override fun onCreate() {
super.onCreate()
Invitebase.configure(this, "pk_test_51Hq2jK")
}
}Call in Application.onCreate() (register the class in your manifest — see Android setup). Restores the anonymous ID from EncryptedSharedPreferences and, on first launch only, queries the Play Install Referrer.
<InvitebaseProvider publishableKey={string} autoResolve={boolean} debug={boolean}>import { InvitebaseProvider } from '@invitebase/react-native';
export default function App() {
return (
<InvitebaseProvider publishableKey="pk_test_51Hq2jK">
<RootNavigator />
</InvitebaseProvider>
);
}React Native configures via the provider component, which calls configure natively and makes the hooks work anywhere below it.
static Future<void> Invitebase.configure({
required String publishableKey,
bool autoResolve = true,
bool debugLogging = false,
})Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Invitebase.configure(publishableKey: 'pk_test_51Hq2jK');
runApp(const MycompanyApp());
}Call before runApp. Identity storage and attribution run in the native SDKs underneath — see Flutter setup.
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.
| Parameter | Type | Description |
|---|---|---|
user.id | string | Required. Your stable ID for this user. |
user.email | string | Optional. Used for self-referral and disposable-email fraud checks. |
user.name | string | Optional. Privacy-safe display name shown to invitees ("You were invited by Alex"). |
user.traits | map | Optional. Arbitrary properties. |
invitebase.identify(user: InvitebaseUser): Promise<void>await invitebase.identify({
id: 'usr_123',
email: 'dana@example.com',
name: 'Dana',
});Invitebase.identify(_ user: InvitebaseUser) async throwstry await Invitebase.identify(
InvitebaseUser(id: "usr_123", email: "dana@example.com", name: "Dana")
)suspend fun Invitebase.identify(user: InvitebaseUser)lifecycleScope.launch {
Invitebase.identify(
InvitebaseUser(id = "usr_123", email = "dana@example.com", name = "Dana")
)
}identify(user: InvitebaseUser): Promise<void>const invitebase = useInvitebase();
await invitebase.identify({ id: 'usr_123', email: 'dana@example.com', name: 'Dana' });static Future<void> Invitebase.identify(InvitebaseUser user)await Invitebase.identify(
InvitebaseUser(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(): voidInvitebase.reset()fun Invitebase.reset()reset(): voidstatic Future<void> Invitebase.reset()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.
| Parameter | Type | Description |
|---|---|---|
preferences.email | boolean | Allow referral emails. Default true. |
preferences.push | boolean | Coming 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 });Invitebase.setNotificationPreferences(_ preferences: NotificationPreferences) async throwstry await Invitebase.setNotificationPreferences(
NotificationPreferences(email: false)
)suspend fun Invitebase.setNotificationPreferences(preferences: NotificationPreferences)lifecycleScope.launch {
Invitebase.setNotificationPreferences(
NotificationPreferences(email = false)
)
}setNotificationPreferences(preferences: NotificationPreferences): Promise<void>const invitebase = useInvitebase();
await invitebase.setNotificationPreferences({ email: false });static Future<void> Invitebase.setNotificationPreferences(NotificationPreferences preferences)await Invitebase.setNotificationPreferences(
NotificationPreferences(email: false),
);Throws an SDK error on failure. The same preferences are settable server-side via POST /v1/referrers.
What's next
getReferralLink — create and share the current user's referral link.
AttributionhandleInbound, resolveReferral, and applyCode — how codes reach the SDK.
Eventstrack — record the events qualification gates evaluate.
Campaigns & progressgetCampaignInfo and getReferrerProgress — the offer and current standing.