The SDK in React Native

React Native apps use the SDK through its module, @squiddy-cloud/react-native, on Android and iOS, with the API of the npm package for the web: plain objects, listeners that return the function that stops them, durations in milliseconds, plus handlePush and pushTopic for the push update. The module is a thin bridge: on Android it runs the SDK's Android library, on iOS its Swift layer and XCFramework, both of the module's own version, so a React Native app has the same stored configuration, conditional checks, backoff, gate and languages as a native one. The React hooks, @squiddy-cloud/react, read the same values in components (React). What the SDK does, what the API key allows and how the SDK behaves offline are on the SDK page; this page is the integration.

Install

npm install @squiddy-cloud/react-native@0.9.0 @squiddy-cloud/react@0.9.0
cd ios && pod install

The module and the hooks are on npm, at version 0.9.0, the same release as on the other platforms. The hooks are optional: an app that reads the values with the listeners installs the module alone.

AndroidiOS
MinimumAPI 24; the app compiles against API 37, with Kotlin 2.4iOS 15.1, with CocoaPods or Swift Package Manager
What the module runscloud.squiddy:squiddy-android, from Maven Centralthe SDK's Swift layer and SquiddyCore.xcframework, which the npm package carries for CocoaPods; the Swift package squiddy-cloud/squiddy-swift with Swift Package Manager
app_type sent to Squiddyandroidios
Bundle idthe application idthe main bundle's identifier
Storagethe app's no-backup files directoryLibrary/Application Support/squiddy, excluded from backups
Push updateyesyes

React Native 0.88 or later, with the New Architecture: the module is a TurboModule, and React Native has no other architecture since 0.82. What each platform asks of the app:

Keep the key out of the repository

The key ends up inside the app, so it is not a secret (see the API key), but like any credential it does not belong in the repository. One way, the sample's: a JSON file that git ignores, which Metro bundles into the app.

{ "SQUIDDY_API_KEY": "sqd_…" }

That is squiddy.local.json, never committed; the app imports it, and a pipeline writes the same file from a secret variable before it builds. A tool such as react-native-config does the same from a .env file.

Initialize

Create one instance per app and Squiddy environment, when the app starts, and keep it: outside the components, in a module of its own, since a component renders more than once. There is no global instance and no automatic start.

// squiddy.ts
import { initialize } from '@squiddy-cloud/react-native';
import settings from './squiddy.local.json';

export const squiddy = initialize({
  host: 'https://squiddy.example.com',
  apiKey: settings.SQUIDDY_API_KEY,
  appId: 'my-app',
  appVersion: '2026.11.29', // YYYY.MM.DD: Squiddy compares it as a number
  appMode: __DEV__ ? 'debug' : 'release',
});

initialize hands the options to the SDK of the platform, which checks every one before it starts, and returns at once, without waiting for the disk or the network: config is pending until the stored configuration is read. Options the SDK refuses throw a SquiddyInitializationError, whose kind is invalid_options (a missing or empty option, a version that is not YYYY.MM.DD, a host that is not an http or https URL) or storage_unavailable (the device gave no place for the files), and whose message names the option to fix. close() stops the updates and the listeners.

Options

Only the first five are required.

OptionDefaultWhat it does
host, apiKey, appId, appVersion, appMode—Required. appVersion is YYYY.MM.DD; appMode is matched against the configuration's modes, such as debug and release
customParamsnoneThe custom parameters the configuration's rules match, sent as given
bundleIdthe platform's (see Install)Another identifier, sent as given
languagethe device'sA language of the app's own, sent as given; setLanguage changes it later
entityIdthe installation idAn opaque id of yours that rollouts place the user by (see rollouts)
timeoutMillis10 secondsThe longest one call may take, in milliseconds
pushRefreshJitterMillisup to 1 minuteThe longest random wait before the check a push update asks for, in milliseconds, so the installations do not call at the same instant
loggernoneA function (level, message, cause): debug lines show the HTTP headers with the key redacted, warning lines the problems the SDK recovered from

How often the SDK checks while the app stays in the foreground is not an option: the configuration decides it with the refreshInterval of its API block, and by default there is no periodic check (the periodic check).

The configuration

config, gate and strings are the values now; onConfig, onGate and onStrings call their listener with the value in a later task, then at every change, and return the function that stops them. A value is the same object while it does not change, and a check that finds the configuration unchanged calls nothing.

const stop = squiddy.onConfig((state) => {
  const timeout = state.configuration?.serverApi?.setting('timeout')?.asInt();
  setTimeoutSeconds(timeout ?? 30);
});

A state has a kind: pending, ready or failed. A ready state has its origin, cache from the device's storage or network once Squiddy sent or confirmed it; a failed one has its error and the configuration still served. A configuration has its version, its serverApi (baseUrl, mode, apiVersion, isDebugActive and settings, with setting(key)), its two notices appUpdate and infoPoint, and its strings. A setting reads as text with value, or with asInt(), asDouble() and asBoolean(), which throw a SettingTypeError naming the setting when the value is not of that type. await squiddy.settled() waits for the first configuration, from the device or from Squiddy.

In components, the hooks of @squiddy-cloud/react follow the same values with useSyncExternalStore, so a component renders again only when what it reads changes:

import { SquiddyProvider, useSquiddyGate, useSquiddyString } from '@squiddy-cloud/react';
import { squiddy } from './squiddy';

export default function App() {
  return (
    <SquiddyProvider squiddy={squiddy}>
      <Home />
    </SquiddyProvider>
  );
}

function Home() {
  const gate = useSquiddyGate();
  const title = useSquiddyString('welcome_title', 'Welcome');
  return gate.kind === 'none' ? <Text>{title}</Text> : <Notice gate={gate} />;
}

React has every hook; they are the same on the web and in React Native.

The gate

gate says which screen the app shows: its kind is none, update_required or maintenance.

squiddy.onGate((gate) => {
  if (gate.kind === 'update_required') showUpdateScreen(gate.title, gate.message);
  else if (gate.kind === 'maintenance') showMaintenanceScreen(gate.title, gate.message);
  else showApp();
});

update_required comes from an app-update notice marked as required for this version, maintenance from an info-point notice that halts the app, and when both apply maintenance wins. Titles and messages arrive already localized by Squiddy; a title or a message left blank for the language arrives empty, and the gate applies all the same. The gate holds for the configuration read from the device too, so a maintenance stays on screen offline, and it is none while there is no configuration at all. The notices stay readable one by one, with their flags, in configuration.appUpdate (isRequired) and configuration.infoPoint (isHalting).

The kinds are closed sets, the same strings as in the browser: until 1.0.0 a minor version may add a member, and says so in the changelog, which makes a switch over a TypeScript union without a default branch stop compiling until it handles it.

Strings

const title = squiddy.string('welcome_title', 'Welcome');

string reads the strings the SDK delivered last, at once, so it serves while a component renders. A string is looked up in the language the SDK asks in, then in the configuration's default language, then the fallback (null without one), and only a key the language does not have goes on to the next. An empty text is a text: a translation left blank in the dashboard is returned empty, with or without the fallback, so a key left blank in a language stays blank in the app. strings is the value of all of them, and onStrings follows it. The configuration holds every language its API block supports, so a change of language changes the strings without a call.

Language

The SDK asks Squiddy in the device's language, and follows it while the app runs. An app with its own language picker calls squiddy.setLanguage('en'), and setLanguage(null) goes back to the device's; a blank language throws a SquiddyLanguageError (invalid_language). When the language changes, the strings switch with the SDK's next value, a moment later (onStrings delivers them), and the SDK checks with Squiddy, in the foreground, for the texts of the notices, which Squiddy localizes for each call.

When the SDK checks

As on the native platforms: at every start, after serving the stored configuration; whenever the app comes back to the foreground; and, if the API block of the configuration has a refreshInterval, at that interval while it stays there (the periodic check). In the background it makes no call. squiddy.refresh() asks for a check now, and the outcome arrives in config.

Push update

Push update is a button on each configuration in the dashboard: Squiddy sends a data-only message of Firebase Cloud Messaging to the configuration's topic, and every installation subscribed to it checks within a random wait of up to pushRefreshJitterMillis. The module does not depend on Firebase: the app subscribes to the topic the SDK gives it, with @react-native-firebase/messaging, and hands the messages it receives to the SDK.

What it takes is what the native apps need: a Firebase project with the app's Android and Apple apps, on iOS the Push Notifications capability, the Remote notifications background mode and an APNs key uploaded to Firebase (see the push update on Android and iOS), and the project's service account key uploaded to the configuration's Push update tab in the dashboard. @react-native-firebase 27 resolves Firebase with Swift Package Manager and, on CocoaPods, asks for dynamic frameworks (use_frameworks! :linkage => :dynamic in the Podfile), which the module supports. Then:

import { getMessaging, onMessage, requestPermission, subscribeToTopic } from '@react-native-firebase/messaging';

const messaging = getMessaging();
await requestPermission(messaging);
await subscribeToTopic(messaging, squiddy.pushTopic);
onMessage(messaging, (message) => {
  squiddy.handlePush(message.data ?? {});
});

handlePush returns true for Squiddy's message, whose data says squiddy = refresh and names its topic in squiddy_topic, and false for any other, which stays the app's.

While the app runs. onMessage delivers the messages that arrive while the app is in the foreground. A message that arrives in the background goes to the background handler of @react-native-firebase/messaging, which runs without the app's instance of the SDK: hand it nothing there, and the SDK checks anyway when the app comes back to the foreground. In a React Native app the push update reaches the installations in the foreground, and the others at their next return.

The topic is squiddy- and 64 hexadecimal digits, computed from the API key and the appId: every installation that reads the same configuration with the same key shares it. A version of the app with another key has another topic: keep the topic you subscribed to and, when pushTopic differs, unsubscribe from the old one.

Errors

A failed check is a failed state whose error has a kind, a message, retryAfterSeconds (for rate_limited, when Squiddy said how long) and exceptionCode (for server_error, when Squiddy sent one). The table of errors says what each one means:

kindError in the table
unauthenticatedUnauthenticated
app_not_publishedAppNotPublished
incomplete_configurationIncompleteConfiguration
invalid_requestInvalidRequest
tenant_suspendedTenantSuspended
rate_limitedRateLimited
server_errorServerError
networkNetwork
timeoutTimeout
malformed_responseMalformedResponse
if (squiddy.config.error?.kind === 'tenant_suspended') tellSomeone();

No other error leaves the module, except SquiddyInitializationError from initialize, SquiddyLanguageError from setLanguage, SettingTypeError from a typed reading of a setting, and an Error that says the app was built without the module's native side (an Expo Go app, or a build made before the installation).

The sample

The SDK's repository has a React Native sample, on Android and iOS (on CocoaPods), with the screen of the other samples: the state of the configuration with a button that checks now, the gate, a localized string, a language picker, the configuration's settings, and the push update with @react-native-firebase/messaging. It starts the SDK with the module, reads it in its components with the hooks, and reads the configuration squiddy-sample, with the key in a squiddy.local.json that git ignores and Metro bundles.