Identify Users with RevenueCat: logIn, logOut & appUserID
Overview
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
logInwith your own user id (or pass one toconfigure), 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 thecustomerInfoplus acreatedflag.logOut(): clear the identified user and switch back to a fresh anonymous id.getAppUserID()/appUserID: read the id RevenueCat is currently using.
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.
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.
// 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';
// 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
// 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
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.
// React Native
await Purchases.logOut();
// The next appUserID will be a fresh anonymous id ($RCAnonymousID:...)
// iOS Swift
let customerInfo = try await Purchases.shared.logOut()
// customerInfo now reflects the new anonymous user
// Android Kotlin (coroutines)
Purchases.sharedInstance.awaitLogOut()
// The next appUserID will be a fresh anonymous id
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.
// React Native
const appUserID = await Purchases.getAppUserID();
console.log('Current RevenueCat appUserID:', appUserID);
// iOS Swift
let appUserID = Purchases.shared.appUserID
print("Current RevenueCat appUserID: \(appUserID)")
// 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
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.
logIn later is the
standard flow for apps where users sign in after opening the app.
logIn when the identity actually changes (sign in or account switch) and
logOut when the user signs out.
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
- Configure the RevenueCat SDK: apiKey and appUserID setup
- Get CustomerInfo & Refresh the Cache: read entitlements after logIn
- Restore Purchases on Android: recover purchases for returning users
- React Native In-App Purchases Tutorial: full end-to-end integration
- iOS In-App Purchases Tutorial: full end-to-end integration
- Android In-App Purchases Tutorial: full end-to-end integration
- RevenueCat Docs: Identifying Users: official reference