Skip to main content
API Reference / modelence / client / configureClient
configureClient(userConfig): void
Defined in: packages/modelence/src/client/clientConfig.ts:48 Configure the Modelence client for non-browser environments like React Native. When configured, the client uses the provided functions for auth-token storage, client-info collection, and URL resolution instead of the default browser APIs (localStorage, window.screen, relative URLs).

Example

import { configureClient } from 'modelence/client';
import { Linking } from 'react-native';

let authToken: string | undefined;

configureClient({
  baseUrl: 'https://myapp.com',
  getAuthToken: () => authToken,
  setAuthToken: (token) => { authToken = token ?? undefined; },
  getClientInfo: () => ({
    screenWidth: Dimensions.get('screen').width,
    screenHeight: Dimensions.get('screen').height,
    windowWidth: Dimensions.get('window').width,
    windowHeight: Dimensions.get('window').height,
    pixelRatio: PixelRatio.get(),
    orientation: null,
  }),
  openUrl: (url) => Linking.openURL(url),
});

Parameters

ParameterType
userConfigClientConfig

Returns

void