React Native

Installation


Our React Native SDK is distributed via npm, and can be installed using your preferred package manager. The react-native-webview package is a peer dependency and will need to be installed as well.

bash npm install @evervault/react-native react-native-webview@13

Compatibility

Our React Native SDK requires React Native 0.76 or higher. We recommend upgrading if possible.

If you are unable to upgrade, you will need to use our legacy React Native SDK.

Linking


This package supports autolinking.

Expo


This library has native code, so it does not work with Expo Go. However, you can install it using a custom development build.

Proguard Rules


If you are using code shrinking with ProGuard for Android, you will need to specify exclusion rules for several Evervault dependencies. The required ProGuard rules can be found in our Android SDK docs.

Quickstart


Add the EvervaultProvider


Wrap your app with the <EvervaultProvider /> component and pass your Team and App ID as props.

Your Team and App ID can be found in the Evervault Dashboard.

Collect Card Data


You can use the <Card /> component to collect card data securely.

If you don't need to collect all four types of supported Card Data, you can omit the relevant components.

However, the components cannot be used individually outside of the <Card /> component.

Perform 3D Secure Authentication


You can use the <ThreeDSecure /> component in combination with the Evervault API to perform 3DS authentications.

In order to use the 3DS component you must first create a 3DS session on your backend and pass it to your frontend. You can then use the <ThreeDSecure.Frame /> component to display the 3DS webview.

Components


<EvervaultProvider />


Wraps your app in a new Evervault context, scoped to a specific team and app.

Props

<Card />


The Card compnent is used to securely collect card holder data from your users.

It is a wrapper component that manages the state of the child input components:

You do not have to render all of the available child input components as children. For example, if you only need to collect a card number and expiry, you can omit the Card.Cvc and Card.Holder components.

The onComplete field will be true once all rendered fields are filled out successfully with valid values.

Props

  • acceptedBrandsRequiredCardBrandName[]

    An array of card brands that are accepted. If not provided, all brands are accepted.

  • defaultValuesRequiredCardForm

    Default values for the card fields.

  • onChangeRequired(payload: CardPayload) => void

    A callback function that is called whenever the card data changes.

  • validationModeRequired'onChange' | 'onBlur' | 'onTouched' | 'all'

    The validation mode for the card fields. Defaults to all.

<Card.Holder />


Used as a child of <Card /> to collect the name of a card holder.

Props

  • placeholderstring

    The placeholder text to display in the input field.

<Card.Number />


Used as a child of <Card /> to collect the card number.

Props

  • placeholderstring

    The placeholder text to display in the input field.

  • obfuscateValueboolean | string

    If true, all but the first 6 characters of the card number will be obfuscated. If a string is provided, it will be used as the obfuscation character (defaults to ).

<Card.Expiry />


Used as a child of <Card /> to collect the expiry date of a card.

Props

  • placeholderstring

    The placeholder text to display in the input field.

<Card.Cvc />


Used as a child of <Card /> to collect the CVC code of a card.

Props

  • placeholderstring

    The placeholder text to display in the input field.

  • obfuscateValueboolean | string

    If true, all of the CVC will be obfuscated. If a string is provided, it will be used as the obfuscation character (defaults to ).

<ThreeDSecure />


The ThreeDSecure component is used to provide access to the 3DS authentication process.

This component allows you to use the <ThreeDSecure.Frame /> component to display the 3DS webview. Any custom components you want to display alongside the 3DS webview should be wrapped in the ThreeDSecure component.

It should be used in combination with the useThreeDSecure hook.

Props

  • sessionRequiredstring

    The 3D Secure session ID.

<ThreeDSecure.Frame />


The ThreeDSecure.Frame component is used to display the 3DS webview, which will handle the authentication process.

If the user closes the frame before completion, you will need to use the cancel() method (from the useThreeDSecure hook) to properly close the webview and clean up the session.

Options

  • themeObject

    Allows you to customize the appearance of the component.

Parameters
  • sessionRequiredstring

    The 3D Secure session ID.

  • optionsThreeDSSessionOptions

    The options for the 3DS authentication process.

Hooks


useEvervault


The useEvervault hook is used to access the current Evervault scope in context.

Any component that uses this hook must be wrapped in the <EvervaultProvider /> component.

Returns


encrypt

Encrypts the provided data using native encryption modules and the Evervault API.

Parameters
  • dataRequiredstring | number | boolean | object | array

    The data to encrypt.

useThreeDSecure


The useThreeDSecure hook is used to manage the 3DS authentication process.

The hook returns an object with start() and cancel() methods. The returned object should be used with the <ThreeDSecure /> component.

Options

  • failOnChallengeboolean | () => Promise<boolean>

    If set to true (or a function that returns true), the authentication will fail if any sessions require a challenge. Can be overridden on a per-session basis by the failOnChallenge option passed to the start() method.

Returns


start

The start function is used to kick off the 3DS authentication process.

Parameters
  • sessionIdRequiredstring

    The 3DS session ID. A 3DS session can be created using the Evervault API.

  • optionsThreeDSSessionOptions

    The options for the 3DS authentication process.

cancel

The cancel() function is used to cancel the ongoing 3DS authentication process. This can be particularly useful for canceling a session when a custom cancel button is triggered.

V2 Migration Guide


If your app currently uses the older @evervault/evervault-react-native package, you can follow our migration guide to upgrade to the new package.