Identify Users with RevenueCat: logIn, logOut & appUserID

Overview

This guide is about identifying users in your app, not signing in to the RevenueCat dashboard. If you searched for "revenuecat login" as a developer integrating the SDK, the method you want is Purchases.logIn(...), which tells RevenueCat who the current user is so their purchases and entitlements follow them across devices. Signing in to app.revenuecat.com to manage your project is a separate, unrelated thing.

Every RevenueCat customer is identified by an appUserID. There are two kinds of users:

  • Anonymous users. If you configure the SDK without passing an app user id, RevenueCat generates one for you. Anonymous ids are prefixed and look like $RCAnonymousID:1a2b3c.... Purchases made while anonymous still work, they are just tied to a RevenueCat-generated id.
  • Identified users. When you call logIn with your own user id (or pass one to configure), the customer becomes identified. The same id used on another device links to the same purchases and entitlements, which is what makes cross-device and cross-platform access work.

The identity API has three pieces:

  • logIn(appUserID): identify the current user. Returns the customerInfo plus a created flag.
  • logOut(): clear the identified user and switch back to a fresh anonymous id.
  • getAppUserID() / appUserID: read the id RevenueCat is currently using.
Prerequisites: The RevenueCat SDK must already be installed and configured with Purchases.configure(...). See the platform codelabs (React Native, iOS, Android) and the Configure the SDK guide for setup.

Configure With or Without an appUserID

You have two valid starting points. If you already know the user's stable id at app launch (for example a persisted session), pass it straight to configure and you may not need logIn at all. If the user authenticates after launch, configure anonymously and call logIn later.

typescript
import Purchases from 'react-native-purchases';

// Option A: known user id at launch (no logIn needed)
Purchases.configure({ apiKey: 'your_public_sdk_key', appUserID: 'my_app_user_id' });

// Option B: unknown user at launch -> start anonymous, call logIn after auth
Purchases.configure({ apiKey: 'your_public_sdk_key' }); // appUserID omitted = anonymous

See the Configure the RevenueCat SDK guide for the full per-platform configure setup. The rest of this guide covers the Option B flow, where you identify the user after they authenticate.

logIn

Call logIn right after your own authentication completes, passing your stable backend user id. It returns the latest customerInfo and a created flag that is true when a new RevenueCat customer was created for that id, and false when an existing one was reused.

typescript
// React Native
import Purchases from 'react-native-purchases';

const { customerInfo, created } = await Purchases.logIn('my_app_user_id');

if (created) {
  console.log('A new RevenueCat customer was created for this id.');
}
const isPro = typeof customerInfo.entitlements.active['premium'] !== 'undefined';
swift
// iOS Swift
import RevenueCat

let (customerInfo, created) = try await Purchases.shared.logIn("my_app_user_id")

if created {
    print("A new RevenueCat customer was created for this id.")
}
let isPro = customerInfo.entitlements["premium"]?.isActive == true
kotlin
// Android Kotlin (coroutines)
import com.revenuecat.purchases.Purchases

val result = Purchases.sharedInstance.awaitLogIn("my_app_user_id")

if (result.created) {
    Log.d("Purchases", "A new RevenueCat customer was created for this id.")
}
val isPro = result.customerInfo.entitlements["premium"]?.isActive == true
Call logIn after your auth completes, not before. The point of logIn is to attach RevenueCat to a known person. Call it once your own login flow has produced a confirmed, stable user id.

logOut

When the user signs out, call logOut. RevenueCat clears the identified user and generates a brand new anonymous appUserID for the device, so the next session starts fresh until you call logIn again.

typescript
// React Native
await Purchases.logOut();
// The next appUserID will be a fresh anonymous id ($RCAnonymousID:...)
swift
// iOS Swift
let customerInfo = try await Purchases.shared.logOut()
// customerInfo now reflects the new anonymous user
kotlin
// Android Kotlin (coroutines)
Purchases.sharedInstance.awaitLogOut()
// The next appUserID will be a fresh anonymous id
logOut is for user sign out, not a reset button. Only call it when the person actually signs out of your app. Calling it leaves the device as a new anonymous user, so any purchases made afterward attach to that anonymous id until the next logIn.

Read the Current appUserID

To check which id RevenueCat is currently using (for debugging, logging, or showing in a support screen), read the app user id. On React Native and Android it is an accessor; on iOS it is a synchronous property.

typescript
// React Native
const appUserID = await Purchases.getAppUserID();
console.log('Current RevenueCat appUserID:', appUserID);
swift
// iOS Swift
let appUserID = Purchases.shared.appUserID
print("Current RevenueCat appUserID: \(appUserID)")
kotlin
// Android Kotlin
val appUserID = Purchases.sharedInstance.appUserID
Log.d("Purchases", "Current RevenueCat appUserID: $appUserID")

If the value starts with $RCAnonymousID:, the current user is anonymous. Any other value is the identified id you passed to logIn or configure.

Best Practices

Use your own stable user id, not an email. Pass a non-personally-identifiable identifier from your backend, such as a database user id or a UUID. Do not use email addresses, usernames, or anything that can change. The appUserID is how RevenueCat links a person to their purchases, so a changing id breaks that link and a guessable id risks exposing customer records.
Call logIn after your auth flow finishes. Identify the user once you have a confirmed, stable id from your own authentication. Configuring anonymously at launch and calling logIn later is the standard flow for apps where users sign in after opening the app.
Do not call logIn and logOut on every launch. The SDK persists the last app user id across launches. Only call logIn when the identity actually changes (sign in or account switch) and logOut when the user signs out.
If you already pass appUserID to configure, you may not need logIn. When the stable id is known at launch and never changes within a session, configuring with it is enough. Reach for logIn when the user authenticates after the app has already started.

For the full reference on user identity, see the official RevenueCat Docs: Identifying Users.

FAQ

Is Purchases.logIn the same as logging into the RevenueCat dashboard?
No. Purchases.logIn is an in-app SDK call that identifies the current user to RevenueCat. Signing in to app.revenuecat.com is how you manage your project. Developers integrating the SDK want Purchases.logIn.

What does the created flag mean?
logIn returns customerInfo and created. created is true when RevenueCat created a new customer for that id, and false when an existing customer with that id was found and reused.

What should I pass as the app user id?
A stable, non-personally-identifiable id from your backend (database id or UUID). Do not use email addresses or anything that can change.

What happens to the appUserID after logOut?
logOut generates a new anonymous appUserID (prefixed with $RCAnonymousID:). The next session is anonymous until you call logIn again.

Related Guides