Skip to main content
Use this page after the Web SDK quickstart when you need to control the browser session lifecycle.

Create the client

The injected provider is the signer used for SIWE. Without provider, providers.web3.driver, or another supported signing strategy, this client can restore compatible session data but cannot start a new wallet sign-in. persistSession defaults to true and uses browser localStorage. Use a stable, environment-specific sessionStorageKeyPrefix so development and production sessions do not collide. Set persistSession: false when the browser must not retain session data.

Sign in or reuse a session

The shortest path is:
signIn() first attempts to restore a valid persisted session. It opens the wallet only when no usable session exists or the configured manifest needs permissions the restored session does not cover. To render separate restoring and wallet-prompt states, call restoreSession() explicitly:
Ordinary restore outcomes are reported as statuses rather than thrown errors:

Handle expiry during an operation

Service calls return Result objects. If a long-lived page sees an expired session, ask the user to sign in again and then retry only the operation that is safe to repeat:
sessionExpirationMs sets the requested lifetime for newly created sessions. It does not extend an already-issued session.

Sign out

signOut() clears the persisted TinyCloud session and in-memory session-scoped state. It does not disconnect or lock the user’s wallet extension. Call signIn() again before the next TinyCloud operation.

Next steps

Verified against @tinycloud/web-sdk 2.7.0-beta.2.