JavaScriptAPI reference
React
React in the JavaScript SDK.
import { NexusProvider, useNexus } from '@inverge/nexus/react'| Symbol | Kind | Summary |
|---|---|---|
NexusProviderProps | interface | |
NexusProvider() | function | Provides a Nexus instance to the tree. |
useNexus() | function | The Nexus instance from context (falls back to the global singleton). |
useTrackEvent() | function | Track an event with a stable callback. |
useFlag() | function | Whether a feature flag is enabled (call nexus.flags.load() first). |
useRemoteConfig() | function | Subscribe to Remote Config; re-renders when the config changes. |
useRemoteConfigValue() | function | A single Remote Config value, re-rendered on change. |
NexusProviderProps
interface @inverge/nexus/reactclient
propertyclient?: NexusProvide either a ready instance, or a config to init one.
config
propertyconfig?: NexusConfigchildren
propertychildren: React.ReactNodeFunctions
NexusProvider()
functionNexusProvider({ client, config, children }: NexusProviderProps): React.ReactElementProvides a Nexus instance to the tree. Pass a config to auto-init, or a
client you created yourself.
Parameters
Prop
Type
Returns React.ReactElement
useNexus()
functionuseNexus(): NexusThe Nexus instance from context (falls back to the global singleton).
Returns Nexus
useTrackEvent()
functionuseTrackEvent(): (name: string, properties?: Record<string, unknown>) => voidTrack an event with a stable callback.
Returns (name: string, properties?: Record<string, unknown>) => void
useFlag()
functionuseFlag(key: string): booleanWhether a feature flag is enabled (call nexus.flags.load() first).
Parameters
Prop
Type
Returns boolean
useRemoteConfig()
functionuseRemoteConfig(): Nexus['remoteConfig']Subscribe to Remote Config; re-renders when the config changes. Returns the
service so you can call getString/getBool/…
Returns Nexus['remoteConfig']
useRemoteConfigValue()
functionuseRemoteConfigValue<T = unknown>(key: string, fallback?: T): TA single Remote Config value, re-rendered on change.
Parameters
Prop
Type
Returns T
