# Constants

> expo-constants wrapped for every SymbioteNative adapter, trimmed to its native fields.

`@symbiote-native/constants` wraps
[`expo-constants`](https://github.com/expo/expo/tree/main/packages/expo-constants) and keeps its
native fields: session ID, status bar height, system fonts, linking URI, execution environment,
device name and year class, the platform block and the WebView user agent. Every field is a plain
value resolved once, so all five adapters re-export the same `Constants` object.

| OS platform | Support |
| ----------- | ------- |
| iOS         | live    |
| Android     | live    |

## Installation

```sh
pnpm add @symbiote-native/constants
```

Scaffolding or extending an app? `npx @symbiote-native/cli new --constants` (or `add --constants`)
installs and wires it. `expo-constants` and `expo-modules-core` come along as pinned dependencies,
never install either yourself and never add the `expo` meta-package.

<Aside type="danger" title="Native setup is required before first use">
  The native code is discovered by `expo-modules-autolinking`, follow [How to:
  wire up an Expo native module](/docs/howtos/expo-native-module-setup/) once per
  app first. On Android the package also registers `ConstantsService`, without
  which the module resolves but every field is empty.
</Aside>

## Usage

```ts
import { Constants, ExecutionEnvironment } from '@symbiote-native/constants';

const isBare = Constants.executionEnvironment === ExecutionEnvironment.Bare;
const sessionId = Constants.sessionId;
const userAgent = await Constants.getWebViewUserAgentAsync();
```

The import path is the same on every adapter: `@symbiote-native/constants`, or the
`/react`, `/vue`, `/svelte`, `/solid` and `/angular` entries.

## Not ported

<Aside type="note" title="No Expo manifest">
  `manifest`, `manifest2`, `expoConfig`, `expoGoConfig` and `easConfig` are left out: upstream
  reads them from a manifest generated by `expo-cli`, EAS or `expo-updates`, and this project has
  none. That is also why `@symbiote-native/auth-session` has no `auth.expo.io` proxy flow and no
  manifest-based scheme detection in `makeRedirectUri`.
</Aside>

## Common questions

- **Where is `Constants.expoConfig`?** Not ported: there is no Expo manifest here, so read
  build-time values from your own config, inlined by your Babel or Metro setup.
- **`Constants.manifest` is `null`.** Upstream deprecated it in favor of `expoConfig`; it is not
  available here either.
- **Where is `installationId`?** Deprecated upstream. Use `@symbiote-native/application`'s Android ID
  on Android and `@symbiote-native/secure-store` for a stored id on iOS.
- **`makeRedirectUri` needs a scheme.** Pass `scheme` explicitly, since auto-detection reads `expoConfig`.

Sources: [Expo docs: Constants](https://docs.expo.dev/versions/latest/sdk/constants/),
[expo/expo#44527](https://github.com/expo/expo/issues/44527),
[Constants manifests and config](https://tessl.io/registry/tessl/npm-expo-constants/18.0.0/files/docs/manifests-config.md).
