User management

Identify users, set attributes, and sign them out.

Beta

The Web SDK is in beta and its API may change between releases.

Identify a user

Call identify once you know who the user is, typically right after sign-in.

await sw.user.identify("user_42");

Before that, the SDK tracks an anonymous alias ID it generates and persists itself, so placements and experiments work for logged-out visitors too.

Restoring paywall assignments

A user who browsed logged-out already has experiment assignments tied to their anonymous identity. Once they sign in, those assignments may not be the ones their real account should see.

Pass restorePaywallAssignments to re-fetch config and re-run assignment for the identified user before identify resolves:

await sw.user.identify("user_42", { restorePaywallAssignments: true });

register calls block until the restore finishes, so the user never gets a paywall picked from their anonymous identity's stale assignments. It is best-effort. If the fetch fails, the cached assignments stay in place.

Reading identity

Identity is exposed as reactive values. Read .value for a snapshot, or .subscribe() to react to changes.

sw.user.id.value;          // "" until identify()
sw.user.aliasId.value;     // the anonymous ID
sw.user.effectiveId.value; // id || aliasId
sw.user.isLoggedIn.value;  // boolean

sw.user.id is an empty string until you call identify. effectiveId returns id when set, otherwise aliasId.

Sign out

await sw.user.signOut();

This clears the identified user and returns the SDK to its anonymous alias.

User attributes

Attributes are values you attach to the user, and your campaign's audience rules can filter on them.

sw.user.setAttributes({
  plan: "team",
  seats: 12,
  signedUpAt: "2026-08-11",
});

setAttributes merges. It does not replace the whole set. Read the current values with sw.user.attributes.value.

Integration attributes

Integration attributes carry third-party identifiers so Superwall can line its data up with your analytics tools.

sw.user.setIntegrationAttribute("amplitudeUserId", "abc123");

sw.user.setIntegrationAttributes({
  amplitudeUserId: "abc123",
  mixpanelDistinctId: "xyz789",
});

Pass null for a value to clear it.

Resetting

reset clears local state (identity, attributes, and cached assignments), then resyncs.

await sw.reset();

Reach for signOut when a user logs out and reset when you want a clean slate, such as between tests.

Next, gate your features.

How is this guide?

On this page