Resolve a service from the global context.
This is the simplest way to access services without dependency on any specific framework. Works in Node.js, Deno, Bun, and browsers.
The service type.
The service token to resolve.
The resolved service instance.
If no context is set.
If the token is not registered.
1.2.0
import { useService, Tokens } from '@oobe-protocol-labs/synapse-client-sdk/context';const rpc = useService(Tokens.RPC);const balance = await rpc.getBalance(pubkey); Copy
import { useService, Tokens } from '@oobe-protocol-labs/synapse-client-sdk/context';const rpc = useService(Tokens.RPC);const balance = await rpc.getBalance(pubkey);
Resolve a service from the global context.
This is the simplest way to access services without dependency on any specific framework. Works in Node.js, Deno, Bun, and browsers.