3DS React Native SDK Enterprise
The Basis Theory 3DS React Native SDK makes it easy to start a 3DS transaction from a React Native mobile app.
Get started with our guide or continue reading the reference docs.
Before You Begin
This SDK requires the use of an API Key associated with a Public Application.
To create one, login into our Portal and create a new "Public" Application with the 3ds:session:create
permission.
Installation
- npm
- yarn
npm install --save @basis-theory/3ds-react-native
yarn add @basis-theory/3ds-react-native
Initialization
BasisTheory3dsProvider
This Context Provider is used to wrap your application and provide the SDK instance to all the components in the tree.
Your app must have the BasisTheory3dsProvider
at the root level to ensure the SDK hook methods are available to all components.
import { BasisTheoryProvider } from "@basis-theory/3ds-react-native";
const App = () => {
return (
<BasisTheory3dsProvider apiKey={"<API_KEY>"}>
<MyApp />
</BasisTheory3dsProvider>
);
}
Initialization Parameters
Parameter | Required | Type | Description |
---|---|---|---|
apiKey | true | string | The API Key used to identify the Application |
apiBaseUrl | false | string | The base URL for the Basis Theory API, if using a mock API |
scriptSrc | false | string | The source URL for the Basis Theory 3DS SDK CDN script |
useBasisTheory
The useBasisTheory
hook provides access to the SDK methods. It must be used within a component that is a descendant of the BasisTheory3dsProvider
.
import { BasisTheory3dsProvider } from "@basis-theory/3ds-react-native";
const App = () => {
return (
<BasisTheory3dsProvider apiKey={"<API_KEY>"}>
<MyApp />
</BasisTheory3dsProvider>
);
}
const MyApp = () => {
const { createSession, startChallenge } = useBasisTheory3ds();
//... rest of your component
}