React Native & Expo
Integrate OnsideKit into a React Native or Expo app with the @onside-io/react-native-onsidekit package — an Expo module over the native iOS SDK.
The @onside-io/react-native-onsidekit package lets you use OnsideKit from JavaScript/TypeScript in a React Native app that ships to iOS. It is built on the Expo Modules API and mirrors the native API one to one: the same objects and calls as Onside in Swift, with no logic of its own. Products, payments and transactions are native-backed objects, so the Core Concepts and Error Reference pages apply as is.
Package:
@onside-io/react-native-onsidekiton npmRequires: Expo SDK 58+, React Native 0.88+, Xcode 27+, iOS 17.4+
Works with: Expo prebuild / development builds and bare React Native projects
Platforms: iOS only — Android is not supported
The package version always matches the native OnsideKit version it bundles: @onside-io/react-native-onsidekit@3.0.1 contains OnsideKit 3.0.1. The OnsideKit.xcframework ships inside the npm package, so pod install needs no extra sources or network access, and your lockfile pins the exact SDK build. The framework includes its device dSYM, so Xcode adds it to your archive and crash reporters symbolicate OnsideKit frames automatically.
1. Install the package
npm install @onside-io/react-native-onsidekit2. Configure the iOS project
Add the config plugin to app.json (or app.config.js):
{
"expo": {
"ios": {
"deploymentTarget": "17.4"
},
"plugins": [
[
"@onside-io/react-native-onsidekit",
{
"callbackScheme": "myapp-onside",
"applePayMerchantId": "merchant.com.yourcompany.app",
"storeKitConfigurationPath": "./TestProducts.storekit"
}
]
]
}
}callbackScheme
Yes
Registers the scheme in CFBundleURLTypes and adds onside to LSApplicationQueriesSchemes. Prebuild fails if it's missing or empty.
applePayMerchantId
No
A merchant ID or an array of IDs, added to the com.apple.developer.in-app-payments entitlement. See Apple Pay.
storeKitConfigurationPath
No
Path (relative to the project root) to a .storekit file. The file is copied into the iOS project and added to the app bundle for local testing.
The plugin also raises the iOS deployment target to 17.4 if it is lower.
Then generate the native project:
Install Expo modules support with
npx install-expo-modules. The package depends onexpo.Set the iOS deployment target to 17.4 or later (
platform :ios, '17.4'in thePodfileand in the Xcode target).Run
cd ios && pod install.In
Info.plist, addonsidetoLSApplicationQueriesSchemesand your callback scheme toCFBundleURLTypes— see Initializing the SDK.Make sure incoming URLs reach React Native
Linking, so you can forward them toOnside.handle(url)— see the next step. The React Native 0.88 app template already does this; if you replaced itsAppDelegateorSceneDelegate, forwardscene(_:openURLContexts:)toRCTLinkingManager.For Apple Pay, add the merchant ID to the Apple Pay capability of your target — see Apple Pay.
3. Initialize and forward callback URLs
Initialize the SDK once at startup, before any other Onside call, then set the callback scheme and forward every incoming URL to Onside.handle(url). The package does not intercept URLs on its own — forward both the URL the app was launched with and URLs received while it runs:
Onside.handle(url) resolves to false for URLs that are not OnsideKit callbacks, so you can route those yourself. Calling any Onside API before initialize() is undefined behavior.
initialize takes the same options as the native call — see Initializing the SDK:
4. Observe the payment queue
Register the transaction listener early — at startup, before the first purchase — so transactions left unfinished in a previous session are delivered too. Keep a long-lived reference to the queue object (for example, in a module-level variable): the native observer is removed when the JS object is garbage-collected.
See The Payment Queue & Transactions for the transaction lifecycle and why every purchased, restored, or failed transaction must be finished.
5. Fetch products
makeProductsRequest returns a request object that reports through events. Keep a reference to it until it finishes:
invalidProductIdentifiers and unsupportedProductIdentifiers list the identifiers that were not returned. See Fetching Products.
6. Make a purchase
add resolves once the payment is accepted into the queue — not when the purchase completes. The result arrives through updatedTransactions. If the user is not logged in, the login flow is presented automatically. See Making a Purchase.
Other features
Restore purchases — restored transactions arrive through updatedTransactions; the end of the restore is reported by queue events:
Login & account — await Onside.requestLogin(), await Onside.logout(), await Onside.presentPaymentMethodsManager(). See Authentication and Managing Payment Methods.
Delegate options — the native OnsideDelegate is configured with plain values:
Payment queue delegate — approve or veto purchases; handlers may be async. A missing handler, or one that throws, counts as true:
See Handling Storefront & Price Changes.
External login — return your app's account token, or null to fall back to the regular login. See External Login:
Appearance — await Onside.appearance().setThemeMode('dark') ('auto' | 'light' | 'dark', or null to reset). See Appearance & Theming.
Attribution & events — await Onside.getAttributionMetadata() resolves to { referer: string | null }; await Onside.track(event, parameters) sends an analytics event. OnsidePredefinedEvent and OnsidePredefinedEventParameter hold the predefined names. See Attribution and Event tracking.
Signed in-app purchase history — await Onside.makeSignedInAppsHistoryRequest() resolves to a request object with the same start() / didReceive / didFail / didFinish shape as the products request; didReceive delivers { dataBase64, string }. See Signed In-App Purchase History.
Installation id & source — publishers that emit the current value and every change:
Onside.installationSource emits 'appStore' | 'onside' | 'unknown' (or null). See Debugging & installationId.
Local testing — pass storeKitConfigurationName to initialize, and await Onside.resetLocalTestingState() to clear local purchase history. See Local Testing.
Errors
Native errors reach JavaScript as string codes that match the native enum cases (.loginDiscarded → 'loginDiscarded'). A code the package version doesn't know maps to 'unknown'.
Rejected promises —
add,restoreCompletedTransactions,requestLogin,presentPaymentMethodsManager,getAttributionMetadataandmakeSignedInAppsHistoryRequestreject with an error whosecodeproperty holds the code.Request events —
didFailon products and signed-history requests, and the queue'srestoreCompletedTransactionsFailed, receive the code as their argument.Failed transactions —
transaction.errorholds the code.
requestLogin
OnsideLoginErrorCode
loginDiscarded
queue.add
OnsideAddPaymentErrorCode
loginDiscarded, rejectedAfterLogin, notSupportedForExternalLogin, applePayRequired, internalError
queue.restoreCompletedTransactions
OnsideRestoreRequestErrorCode
loginDiscarded, internalError
restoreCompletedTransactionsFailed
OnsideTransactionsRestoreErrorCode
cancelled, connectionError, appNotRegistered, serviceUnavailable, internalError
transaction.error
OnsidePaymentTransactionErrorCode
cancelled, presentationFailed, internalError
presentPaymentMethodsManager
OnsidePaymentMethodsManagerErrorCode
loginDiscarded, notSupportedInLocalTesting, notSupportedForExternalLogin, presentationFailed
Products didFail
OnsideProductsRequestErrorCode
cancelled, connectionError, appNotRegistered, invalidProductIdentifier, serviceUnavailable, internalError
getAttributionMetadata
OnsideAttributionMetadataErrorCode
connectionError, appNotRegistered, serviceUnavailable, internalError
Signed history
OnsideSignedInAppsHistoryErrorCode
notLoggedIn, notSupportedInLocalTesting, cancelled, connectionError, appNotRegistered, serviceUnavailable, internalError
Every type also includes unknown. For what each code means, see the Error Reference.
Object lifetime
Products, responses, payments, transactions, requests and the payment queue are native-backed shared objects. A native object lives while its JS object is reachable:
Keep the payment queue in a long-lived variable — when it is collected, its transaction observer and delegate are removed.
Keep requests referenced until
didFinishordidFail.Remove listeners you no longer need with
subscription.remove()orremoveAllListeners(eventName).
See Threading & Object Lifetime for the native rules.
API Reference
Onside
initialize(options?: { disableSSLPinning?: boolean; storeKitConfigurationName?: string | null }): Promise<void>
Initialize the SDK. Call once, before anything else.
isInitialized(): Promise<boolean>
Whether initialize has been called.
setCallbackScheme(scheme: string | null) / getCallbackScheme()
The URL scheme the Onside app returns to.
setApplePayMerchantIdentifier(id: string | null) / getApplePayMerchantIdentifier()
Apple Pay merchant ID.
handle(url: string): Promise<boolean>
Forward an incoming URL; false if it isn't an OnsideKit callback.
setDelegate(delegate: OnsideDelegate | null)
Login method, region hint, window level, orientation override.
setExternalLoginDelegate(delegate: OnsideExternalLoginDelegate | null)
Supply an external account token.
appearance().setThemeMode(mode: 'auto' | 'light' | 'dark' | null)
Global theme.
requestLogin(): Promise<void>
Present the login flow.
logout(): Promise<void>
End the current session.
presentPaymentMethodsManager(): Promise<void>
Show the saved-cards manager.
makeProductsRequest(ids: string[]): OnsideProductsRequest
Create a products request.
makeSignedInAppsHistoryRequest(): Promise<OnsideSignedInAppsHistoryRequest>
Create a signed purchase-history request.
defaultPaymentQueue(): OnsidePaymentQueue
The shared payment queue.
getAttributionMetadata(): Promise<OnsideAttributionMetadata>
Attribution metadata.
track(event: string, parameters: Record<string, OnsideEventParameterValue>): Promise<void>
Send an analytics event.
installationId, installationSource
Publishers: subscribe(listener) returns a subscription with remove().
resetLocalTestingState(): Promise<void>
Reset local-testing purchase history.
OnsidePaymentQueue
add(payment: OnsidePayment): Promise<void>
Start a purchase. Resolves when the payment is enqueued.
finishTransaction(transaction): Promise<void>
Finish a purchased, restored or failed transaction.
restoreCompletedTransactions(): Promise<void>
Restore non-consumables and subscriptions.
getTransactions(): Promise<OnsidePaymentTransaction[]>
Unfinished transactions in the queue.
getStorefront(): Promise<OnsideStorefront | null>
The current storefront.
setDelegate(delegate: OnsidePaymentQueueDelegate | null)
shouldContinue / shouldContinueAfterLogin handlers.
Events
updatedTransactions, removedTransactions, restoreCompletedTransactionsFinished, restoreCompletedTransactionsFailed, didChangeStorefront.
Types
OnsideProduct—productIdentifier,localizedTitle,localizedDescription,iconUrl,price,subscriptionGroupIdentifier(the localized group name, not a stable identifier),subscriptionPeriod. See Models.OnsidePayment—new OnsidePayment(product);product,appAccountToken.OnsidePaymentTransaction—id,transactionIdentifier,originalTransactionIdentifier,payment,transactionState('purchasing' | 'purchased' | 'restored' | 'failed' | 'unknown'),storefront,error,isSame(other).OnsideStorefront—id,countryCode.OnsidePrice—value,currencyCode;OnsidePeriod—unit('day' | 'week' | 'month' | 'year' | 'unknown'),numberOfUnits.
All types are exported from the package with full TypeScript definitions.
Common issues
Cannot find native module 'OnsideKit'— you are running in Expo Go, or the native project wasn't rebuilt after installing the package. Runnpx expo prebuild(orpod install) and rebuild the app.Prebuild fails with
`callbackScheme` must be configured— add thecallbackSchemeoption to the config plugin.The app crashes at launch with "UIScene life cycle is required" — apps built with the iOS 27 SDK must use the scene-based life cycle. Use Expo SDK 58 or later, whose app template already adopts it.
Login or payment never returns to the app — the scheme in
setCallbackSchemedoesn't match the one inInfo.plist, or incoming URLs aren't forwarded toOnside.handle(url).Transactions from a previous session never arrive — the
updatedTransactionslistener was added too late, or the queue object was garbage-collected. Register it at startup and keep a reference.
Last updated
Was this helpful?