For PartnersFor Acquiring Partners
Klarna

Klarna WebView - React Native

This guide walks you through adding the Klarna WebView to your React Native app and using it.
Checkout screen with Klarna selected as the payment method
Klarna purchase flow overview screen with the Continue with Klarna button
Order confirmation screen after a successful payment
Your checkout screen when Klarna is selected as the payment method.The Klarna purchase flow starts when the customer selects Continue with Klarna.Your order confirmation screen after a successful payment.

Integration steps

  • Prepare: Make sure you have a web checkout integrated with Klarna Payments.
  • Set up your app (Mobile App): Set up the return URL for your application.
  • Present your web checkout (Mobile App): Present your web checkout using Klarna WebView from Mobile SDK.
  • Load your checkout page (Mobile App): Load your web checkout in the KlarnaStandaloneWebView.

Prepare

This guide will lead you through all the steps required to accept Klarna Payments in your mobile app using your web integration. At the end, you will be able to accept payments with Klarna in your app using your existing web checkout.
This guide assumes that you already have a web checkout integrated with Klarna Payments and you intend to use it in your mobile application. If you don't have a web integration yet, check the web payments documentation.

Requirements

KlarnaStandaloneWebView supports both the Old and the New Architecture of React Native. On iOS, it supports the iOS versions that your React Native version supports. On Android, it requires Android 5.0 (API level 21) or later. To use every prop on this page, install version 2.10.0 or later of react-native-klarna-inapp-sdk.

Set up your app

Package managers

NPM

To add the SDK with npm, run:
BASH
1 2
npm install react-native-klarna-inapp-sdk --save

Yarn

To add the SDK with Yarn, run:
BASH
1 2
yarn add react-native-klarna-inapp-sdk
To install the iOS dependencies, go to your ios directory and run pod install.

Return URL

Klarna purchase flows can open other apps, for example a bank app to authorize a payment, or the Klarna app. A return URL lets those apps send the customer back to the flow in your app. Pass it to the component with the required returnUrl prop. How you set it up depends on the platform, as described in Android and iOS.

Android

Add the Klarna Mobile SDK repository to your app's build.gradle:
GROOVY
1 2 3 4 5 6 7 8 9 10
allprojects { repositories { ... // Required configuration to fetch native Android SDK maven { url 'https://x.klarnacdn.net/mobile-sdk/' } } }

Return handling

From version 2.4.8 of the react-native-klarna-inapp-sdk package, the SDK registers return handling automatically, derives the return URL from your app's package name and ignores the returnUrl prop. You don't need to add your own intent filter to AndroidManifest.xml.

iOS

Return URL scheme

A redirect to your return URL should only bring your app to the front, without changing the UI state, so the customer can continue the flow where they left it.
You can set up a return URL app scheme for your application by configuring a custom URL scheme.
Integration requirement
The return URL string passed to Klarna must include :// after the scheme name. For example, if you defined myApp as the scheme, you must use "myApp://" as the return URL argument to Klarna.
To avoid a Klarna-specific app scheme, you can use a host in your existing scheme for Klarna redirects, for example myApp://klarna-redirect. This lets you tell these redirects apart in your handler.
Considering the return URL is a constant value in Constants.klarnaReturnUrl, you can handle redirects to your return URL as such:
SWIFT
1 2 3 4 5 6 7 8 9 10
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let url = URLContexts.first?.url else { return } if (url.absoluteString.starts(with: Constants.klarnaReturnUrl.absoluteString)) { // This is a return URL for Klarna: skip deep linking return } // This was not a return URL for Klarna }

Klarna app URL queries

Klarna flows on mobile use Application Queries for Klarna app schemes to offer seamless app handover experience to customers. In order for the SDK to check availability of the Klarna app, we need you to enable querying Klarna app on the device by adding Klarna app schemes to LSApplicationQueriesSchemes.
To configure this in Xcode, open your project settings and go to Info, or open your Info.plist file. Add the klarna and klarnaconsent schemes to the Queried URL Schemes list:
Xcode Info tab with klarna and klarnaconsent in the Queried URL Schemes list

Present your web checkout

Create Klarna WebView

After adding the required dependency you can import the KlarnaStandaloneWebView component and use it like so:
TYPESCRIPT
1 2 3 4 5 6 7 8 9 10
import { useEffect, useRef } from 'react'; import { KlarnaStandaloneWebView, KlarnaTheme, KlarnaWebViewKlarnaMessageEvent, KlarnaWebViewError, KlarnaWebViewNavigationEvent, KlarnaWebViewProgressEvent, KlarnaWebViewRenderProcessGoneEvent, } from 'react-native-klarna-inapp-sdk';
KlarnaStandaloneWebView is a React Native component that wraps the web view of each platform and adds Klarna features, such as handling return URLs and Klarna messages. It doesn't support every prop of other React Native WebView libraries. The following table lists the props it supports. Its methods are listed in Methods.
PropTypeDescription
returnUrlstringRequired. The app scheme URL that you set up in Return URL, used to return from external applications. Used on iOS only: on Android, the SDK derives the return URL from your app's package name.
sourceobjectOptional. Loads a page when the component mounts and whenever its uri or headers change. It has a required uri string and an optional headers object. See Load a page with the source prop. Requires version 2.10.0 or later.
themeKlarnaThemeOptional. Sets the theme of the Klarna components displayed inside the KlarnaStandaloneWebView. Defaults to KlarnaTheme.Light. See Themes. Requires version 2.10.0 or later.
overScrollModestringOptional, Android only. Sets the overscroll mode of the web view to 'always', 'never' or 'content'. Defaults to 'always'.
bouncesbooleanOptional, iOS only. Controls whether the web view's scroll view bounces past the edge of the content and back again. Defaults to true.
sharedCookiesEnabledbooleanOptional, iOS only. Copies the cookies from the app's shared cookie storage (HTTPCookieStorage.shared) into the web view before every load call and every source load. The copy isn't filtered by host and can overwrite newer cookies in the web view's cookie store. Defaults to false. It has no effect on Android, where web views already share cookies. Requires version 2.10.0 or later.
styleViewStyleOptional. Styles the KlarnaStandaloneWebView.
onLoadStartfunctionOptional. A callback that is called when the KlarnaStandaloneWebView starts loading or reloading a URL. Its only parameter is a KlarnaWebViewNavigationEvent.
onLoadEndfunctionOptional. A callback that is called when the KlarnaStandaloneWebView finishes loading a URL. Its only parameter is a KlarnaWebViewNavigationEvent.
onLoadProgressfunctionOptional. A callback that is called while the KlarnaStandaloneWebView is loading a URL. Its only parameter is a KlarnaWebViewProgressEvent, whose progress value goes from 0 to 100.
onErrorfunctionOptional. A callback that is called when the KlarnaStandaloneWebView fails to load a URL. Its only parameter is a KlarnaWebViewError.
onKlarnaMessagefunctionOptional. A callback that is called when the KlarnaStandaloneWebView receives a message from a Klarna component. Its only parameter is a KlarnaWebViewKlarnaMessageEvent.
onRenderProcessGonefunctionOptional, Android only. A callback that is called when the KlarnaStandaloneWebView process crashes or is killed by the OS. Its only parameter is a KlarnaWebViewRenderProcessGoneEvent.

Themes

The theme prop accepts the following KlarnaTheme values. It sets the style of the Klarna components inside the web view. It doesn't change how your own web pages look.
ValueDescription
KlarnaTheme.LightLight style.
KlarnaTheme.DarkDark style.
KlarnaTheme.AutomaticFollows the system's user interface style.

Load your checkout page

Inside MyKlarnaStandaloneWebView from Create Klarna WebView, call the load method on the ref to load your web checkout or any other web page in the KlarnaStandaloneWebView. For example, load your checkout page once the component mounts:
TYPESCRIPT
1 2 3 4 5
useEffect(() => { // Load your checkout page where Klarna Payments is integrated klarnaStandaloneWebViewRef.current?.load('https://www.merchant.com/checkout'); }, []);

Load a page with the source prop

Use the source prop instead of load when the page needs its own headers or cookies, for example a signed-in session on your site. The page loads when the component mounts and again whenever uri or headers change. You can still call load to open another page.
TYPESCRIPT
1 2 3 4 5 6 7 8 9 10
<KlarnaStandaloneWebView returnUrl={'returnUrl://'} source={{ uri: 'https://www.merchant.com/checkout', headers: { Cookie: `session=${sessionId}`, 'X-Store-Id': storeId, }, }} onError={(event: KlarnaWebViewError) => {
Keep the following in mind:
  • uri needs a scheme and a host. Use https.
  • Headers are sent with the first request and its same-origin redirects. They are dropped when the page redirects to another origin.
  • Klarna hosts, such as klarna.com and its subdomains, never receive headers or cookies from source.
  • A Cookie header isn't sent as a header. The SDK stores its cookies for the host of uri before the page loads. These are session cookies. All web views in your app share them, and they stay after the component unmounts. The host of uri needs a registrable domain, such as merchant.com. A Cookie header for localhost, an IP address or a single-label host is rejected.
  • An invalid source loads nothing, and neither does a source with headers for a Klarna host. Both are reported through onError with the code -1 and the reason in description.

Methods

Call the methods on a ref to the component, for example klarnaStandaloneWebViewRef.current?.reload().
MethodDescription
load(url: string)Loads the URL in the web view.
reload()Reloads the current page.
goBack()Goes back to the previous page in the web view's history.
goForward()Goes forward to the next page in the web view's history.
stopLoading()Cancels a page load that is in progress. No onLoadEnd or onLoadProgress events are sent for the cancelled load. Introduced in version 2.9.0, so use version 2.9.0 or later.

What's next

Klarna Mobile SDK provides a full suite of mobile-first integrations, including Klarna products like:
Sign in with Klarna
On-Site Messaging
Express Checkout
Sign in with KlarnaOn-Site MessagingExpress Checkout
Complete your integration with:
Support
Partner support•Service Status
Cookies|Terms & Conditions|Copyright Klarna AB 2026