SolidJS

The SolidJS adapter (@txnlab/use-wallet-solid) provides primitives and components for integrating use-wallet into Solid applications. This guide covers how to set up the adapter and use its features effectively.

Setup

After installing the package and any required wallet dependencies (see Installation) and configuring your WalletManager, wrap your application with the WalletProvider:

import {
  WalletProvider,
  WalletManager,
  NetworkId,
} from '@txnlab/use-wallet-solid'

// Create manager instance (see Configuration guide)
const manager = new WalletManager({
  wallets: [...],
  networks: {...},
  defaultNetwork: NetworkId.TESTNET
})

function App() {
  return (
    <WalletProvider manager={manager}>
      <YourApp />
    </WalletProvider>
  )
}

The provider makes the wallet functionality available throughout your application via Solid's primitives.

Using the Primitives

The Solid adapter provides two primitives for accessing wallet functionality. In v4.0.0, network-related features were moved from useWallet into a new useNetwork primitive to provide better separation of concerns:

useWallet

The useWallet primitive provides access to wallet management features. Here's an example showing some commonly used values:

Note that unlike React's hooks, Solid's primitives return signals (functions) that need to be called to access their current value. The values are automatically tracked and will trigger reactivity when they change.

For a complete list of all available properties and methods, see the useWallet API Reference.

useNetwork

The useNetwork primitive serves two primary functions: managing the active network and supporting runtime node configuration.

Active network management (previously part of useWallet) enables users to switch between different networks.

Runtime node configuration, introduced in v4.0.0, enables users to override the application's default node settings and connect to any Algorand node. See the Runtime Node Configuration guide for details about implementing this feature.

For a complete list of all available properties and methods, see the useNetwork API Reference.

Next Steps

Last updated