@sqds/grid-react-native
v1.0.3
Published
React Native hooks and components for Grid SDK
Keywords
Readme
@sqds/grid-react-native
React Native SDK for Grid - authentication, smart accounts, and payments.
Installation
npm install @sqds/grid-react-nativeRequired Polyfills
IMPORTANT: Configure polyfills at your app's entry point before importing any other code.
1. Install Dependencies
npm install text-encoding react-native-get-random-values buffer @ethersproject/shims2. Configure Polyfills
Create a file entrypoint.js:
import 'text-encoding';
import 'react-native-get-random-values';
import { Buffer } from 'buffer';
global.Buffer = Buffer;
import '@ethersproject/shims';
import 'expo-router/entry';Set this as your entry point in package.json:
{
"name": "your-app-name",
"main": "entrypoint.js"
}Quick Start
import { GridClient } from '@sqds/grid-react-native';
const gridClient = new GridClient({
environment: 'sandbox',
apiKey: '<your api key>'
});
try {
const sessionSecrets = await gridClient.generateSessionSecrets();
await gridClient.createAccount({
email: '[email protected]'
});
const otpCode = '123456';
const response = await gridClient.completeAuthAndCreateAccount({
email: '[email protected]',
code: otpCode,
sessionSecrets
});
console.log('Authentication successful:', response.data);
} catch (error) {
console.error('Authentication failed:', error.message);
}Note: After calling createAccount, an OTP code will be sent to the user's email. The user must enter this code, which you then pass to completeAuthAndCreateAccount to complete the authentication flow.
License
MIT
