Enable Klarna Payment messaging on your online store with Klarna's Mobile SDK and boost transparency and conversion. This includes our pre-qualification feature, which allows customers to check their eligibility for Klarna financing before completing a payment request. This reduces friction and increases confidence, as customers know their options upfront.
![]() | ![]() | ![]() |
| Messaging on the homepage | Messaging on the product detail page | Messaging in the checkout |
Before you integrate On-site messaging, please check that you meet the following conditions:
​Adding On-Site Messaging to your native app is a straightforward process. At a high level, to achieve this tailored experience for your users, you will need to follow these steps:
react-native-klarna-inapp-sdk npm package.KlarnaOSMView component to your screen and provide the required props.npm install react-native-klarna-inapp-sdk --save
yarn add react-native-klarna-inapp-sdk
Check the npm package page for the latest release.
The Android integration depends on the native Klarna Mobile SDK hosted on Klarna's Maven repository. Add the repository to your app's android/build.gradle:
allprojects {
repositories {
// ... existing repositories ...
maven {
url 'https://x.klarnacdn.net/mobile-sdk/'
}
}
}
Install the CocoaPods dependencies:
cd ios && pod install
No additional configuration is required. The podspec in react-native-klarna-inapp-sdk automatically pulls the correct native iOS SDK.
The React Native wrapper pins compatible native SDK versions. See the Mobile SDK versioning policy for details on version compatibility.
Import KlarnaOSMView from the SDK and add it to your screen. The component handles initialization, rendering, and auto-resizing internally.
import React from 'react';
import { View, StyleSheet } from 'react-native';
import {
KlarnaOSMView,
KlarnaEnvironment,
KlarnaRegion,
KlarnaTheme,
} from 'react-native-klarna-inapp-sdk';
function ProductScreen() {
return (
<View style={styles.container}>Auto-sizing: The KlarnaOSMView automatically adjusts its height based on the rendered content. You do not need to set a fixed height — the component emits an internal onResized event and updates its layout.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | The client identifier from the Klarna Portal. If the integration is done by a PSP/distribution partner, use the distribution partner's own client ID. |
| string | Yes | Determines the placement type. See Placement keys. |
| string | Yes | Locale for the messaging content in BCP 47 format (e.g. en-US, de-DE, sv-SE). |
| string | Yes | Purchase amount in minor units as a string. For example, $120.00 = "12000". Used for amount-based credit promotions. |
| KlarnaEnvironment | Yes |
KlarnaEnvironment.Playground. |
| KlarnaRegion | Yes | Klarna region: KlarnaRegion.EU, KlarnaRegion.NA, or KlarnaRegion.OC. |
| KlarnaTheme | No | Visual theme for the placement. Defaults to KlarnaTheme.Automatic. |
| string | No | Custom background colour as a hex string (e.g. "#FFFFFF"). |
| string | No | Custom text colour as a hex string (e.g. "#000000"). |
| string | No | Deep link URL for returning to your app after external flows. The native SDK handles this internally in most cases. |
| (error) => void | No | Callback invoked when an error occurs. See Error handling. |
| ViewStyle | No | Standard React Native view style. Width defaults to 100%; height auto-sizes. |
| Placement Key | Description !Best for |
|---|---|
| Compact badge-style placement showing a Klarna logo alongside a financing message. Fixed height. Product detail pages, cart summaries, inline promotions where space is limited. |
| Auto-sizing placement that adjusts to fit the content. Can display richer messaging. Homepages, category pages, checkout screens where the view can expand. |
| Value | Description |
|---|---|
| Compact badge-style placement showing a Klarna logo alongside a financing message. Fixed height. |
| Dark style for the placement view. Best on dark backgrounds. |
| Follows the system's user interface style (light/dark mode). Default. |
Provide an onError callback to handle errors from the OSM view. The callback receives a KlarnaMobileSDKError object:
interface KlarnaMobileSDKError {
readonly isFatal: boolean; // Whether the error is unrecoverable
readonly message: string; // Human-readable error description
readonly name: string; // Error type identifier
}
Sample code
<KlarnaOSMView
clientId="your-client-id"
placementKey="credit-promotion-badge"
locale="en-US"
purchaseAmount="12000"
environment={KlarnaEnvironment.Production}
region={KlarnaRegion.NA}
onError={(error) => {
if (error.isFatal) {
// Fatal error — OSM cannot render
// Consider hiding the placement or showing a fallback
console.error(`[OSM Fatal] ${error.name}: ${error.message}`);Graceful degradation: When an error occurs, the KlarnaOSMView collapses its height to 0, effectively hiding itself. This means a failed OSM placement won't break your layout — but you should still log errors for monitoring.
clientId is valid and the domain is allowlisted in the Klarna Portal.purchaseAmount is a numeric string in minor units (e.g. "12000" for $120.00).environment is set to Playground for testing and Production for live.region matches the market of the customer (EU, NA, or OC).locale matches the region and language of the customer.build.gradle.pod install has been run after adding the dependency.onError callback is wired up and errors are logged.KlarnaTheme.Automatic to verify correct appearance.Use KlarnaEnvironment.Playground during development and testing. The playground environment returns simulated messaging content without requiring a live merchant account.
<KlarnaOSMView
clientId="your-client-id"
placementKey="credit-promotion-badge"
locale="en-US"
purchaseAmount="12000"
environment={KlarnaEnvironment.Playground}
region={KlarnaRegion.NA}
/>
| Symptom | Likely cause | Fix |
|---|---|---|
| Placement doesn't appear | Invalid clientId or domain not allowlisted. | Verify your client ID in the Klarna Portal and ensure the domain is allowlisted. |
| Android build fails with missing dependency | Klarna Maven repository not added. | Add maven { url 'https://x.klarnacdn.net/mobile-sdk/' } to your build.gradle. |
| Placement renders but shows no content | Invalid purchaseAmount format. | Ensure the amount is a numeric string in minor units (e.g. "12000" not "120.00"). |
InvalidPurchaseAmount | Non-numeric value passed to purchaseAmount. | Strip non-numeric characters before passing the value. |
| View has zero height | An error occurred and the view collapsed. | Check the onError callback for details. |
| Content looks wrong in dark mode | Theme set to Light on a dark background. | Use KlarnaTheme.Automatic to respect system dark mode. |
| Placement doesn't update when amount changes | Same component instance with stale props. | Ensure you pass a new purchaseAmount string. The component re-renders automatically on prop changes. |