React Native hooks and components for Grid SDK
npm install @sqds/grid-react-nativeReact Native SDK for Grid - authentication, smart accounts, and payments.
``bash`
npm install @sqds/grid-react-native
IMPORTANT: Configure polyfills at your app's entry point before importing any other code.
`bash`
npm install text-encoding react-native-get-random-values buffer @ethersproject/shims
Create a file entrypoint.js:`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:`json`
{
"name": "your-app-name",
"main": "entrypoint.js"
}
`typescript
import { GridClient } from '@sqds/grid-react-native';
const gridClient = new GridClient({
environment: 'sandbox',
apiKey: '
});
try {
const sessionSecrets = await gridClient.generateSessionSecrets();
await gridClient.createAccount({
email: 'user@example.com'
});
const otpCode = '123456';
const response = await gridClient.completeAuthAndCreateAccount({
email: 'user@example.com',
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.
MIT