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

OptionTypeDescription
apiKeystringAPI key starting with flsh_
tokenstringJWT — use this in the mobile app
baseUrlstringOverride the API base URL (default: https://vendors.tryflasho.com)

Either apiKey or token is required.

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 classWhen thrown
FlashoApiErrorAPI returned a non-2xx HTTP status
FlashoNetworkErrorRequest failed before a response was received