createSatelliteConnectStore()
createSatelliteConnectStore<
C,W>(params):StoreApi<ISatelliteConnectStore<C,W>>
Defined in: store/satelliteConnectStore.ts:66
Creates the Satellite Connect store: a vanilla Zustand store (zustand/vanilla) that holds the wallet connections
and the actions described in ISatelliteConnectStore. It has no UI and no framework dependency;
SatelliteConnectProvider from @tuwaio/satellite-react creates one for React apps.
Pass one adapter or an array of adapters (one per chain family) as adapter, and optionally a
callbackAfterConnected. Every call creates an independent store.
The state lives in memory. The actions read and write these localStorage keys through the helpers of
@tuwaio/orbit-core (nothing is read or written on the server):
orbit-core:lastConnectedConnector:{ connectorType, chainId, address }of the active connection, wherechainIdis the chain the wallet is connected to, as normalized by the adapter. Written byconnect,switchConnection,disconnectwhile other connections remain, andupdateActiveConnectionwhen the active connection changes chain; removed when the last connection is disconnected.initializeAutoConnectreads it, and so does@tuwaio/pulsar-solana.orbit-core:recentlyConnectedConnectorsListHelpers:{ [connectorType]: { address, disconnectedTimestamp, icon } }, updated with the current time on everyconnect.initializeAutoConnectremoves entries older than 7 days.satellite-connect:impersonatedAddress: removed bydisconnectAlland when the last connection is disconnected.
The store’s Immer instance does not freeze state, because connections hold wallet objects that must stay mutable. It does not change the global Immer settings of the app.
Type Parameters
C
C
Type of the wallet connectors of the adapters.
W
W extends BaseConnector = BaseConnector
Chain-specific connection type.
Parameters
params
SatelliteConnectStoreInitialParameters<C, W>
Store parameters: adapter and the optional callbackAfterConnected.
Returns
StoreApi<ISatelliteConnectStore<C, W>>
The store (StoreApi from zustand/vanilla).
Example
import { createSatelliteConnectStore } from '@tuwaio/satellite-core';
import { type ConnectorEVM, type EVMConnection, satelliteEVMAdapter } from '@tuwaio/satellite-evm';
import { type Config } from '@wagmi/core';
import { mainnet } from 'viem/chains';
declare const wagmiConfig: Config;
const store = createSatelliteConnectStore<ConnectorEVM, EVMConnection>({
adapter: satelliteEVMAdapter(wagmiConfig, [mainnet]),
});
await store.getState().connect({ connectorType: 'evm:metamask', chainId: mainnet.id });
console.log(store.getState().activeConnection?.address, store.getState().connectionError?.message);