Skip to main content

User settings

Change User ID

During registration, login, or account switching, you can update the user identifier at runtime using setUserId:

// Set new user ID (with optional HMAC signature or null)
storyManager.setUserId('<user-id>', null);
Please note

Do not use personal data (phone numbers, email addresses, passport info) as a user identifier. userId must not exceed 255 bytes.

All mounted StoriesList instances will automatically reload and show content tailored to the new user.

User Identifier Signature (HMAC Authentication)

The userIdSign parameter provides an HMAC signature for verifying the authenticity of the user. This ensures that the provided userId is authenticated and has not been tampered with.

const storyManager = await StoryManager.create({
apiKey: '<your-api-key>',
userId: '<user-id>',
userIdSign: 'hmac_signature_token',
});

To update both userId and userIdSign at runtime:

storyManager.setUserId('<user-id>', 'hmac_signature_token');

Anonymous Mode

If your application allows guest browsing without tracking a specific user identity, enable anonymous: true. In this mode, no user identifier is sent to the InAppStory platform:

const storyManager = await StoryManager.create({
apiKey: '<your-api-key>',
anonymous: true,
});

User logout

Use logout() to clear the native user session on the device:

storyManager.logout();

When tearing down a manager instance and creating a new one on user change, remember to call destroy() on the previous instance:

oldStoryManager.destroy();
const newStoryManager = await StoryManager.create({
apiKey: '<your-api-key>',
userId: '<user-id>',
});