Configure the React Native SDK with a JWT or API key.
Setup & Authentication
Setup & Authentication
Create one FlashoClient and reuse it for the life of the app.
// src/flasho.ts
import { FlashoClient } from 'flasho-merchant-sdk';
export const flasho = new FlashoClient({ token: 'placeholder' });Options
| Option | Type | Description |
|---|---|---|
apiKey | string | API key starting with flsh_ |
token | string | JWT — use this in the mobile app |
baseUrl | string | Override the API base URL (default: https://vendors.tryflasho.com) |
Either apiKey or token is required.
JWT login (recommended)
Mobile apps should log in with dashboard email and password. The SDK stores the JWT and sends it on later calls.
import { flasho } from './flasho';
export async function signIn(email: string, password: string) {
const { merchant } = await flasho.auth.login({ email, password });
return merchant;
}⚠️ Do not ship an API key in the app
An flsh_ key in the binary can be extracted. Use JWT login for React Native. Keep API keys on a server.
Error handling
import { FlashoApiError, FlashoNetworkError } from 'flasho-merchant-sdk';
try {
const { delivery } = await flasho.deliveries.create(request);
} catch (err) {
if (err instanceof FlashoApiError) {
if (err.isUnauthorized) {
// Token expired — send the user back to login
}
if (err.isValidationError) {
// Missing field or insufficient wallet balance
}
} else if (err instanceof FlashoNetworkError) {
// Device is offline
}
}| Error class | When thrown |
|---|---|
FlashoApiError | API returned a non-2xx HTTP status |
FlashoNetworkError | Request failed before a response was received |