Skip to main content

Composables

Composables are functions that will help you control the modal, subscribe to wallet events and interact with them and smart contracts.

useAppKit

Composable function for controlling the modal.

import { useAppKit } from '@reown/appkit/vue'

export default function Component() {
const { open, close } = useAppKit()
}

Returns

  • open: Function to open the modal
  • close: Function to close the modal

Parameters

You can also select the modal's view when calling the open function

open({ view: 'Account' })

List of views you can select

VariableDescription
ConnectPrincipal view of the modal - default view when disconnected
AccountUser profile - default view when connected
AllWalletsShows the list of all available wallets
NetworksList of available networks - you can select and target a specific network before connecting
WhatIsANetwork"What is a network" onboarding view
WhatIsAWallet"What is a wallet" onboarding view
OnRampProviders"On-Ramp main view
Swap"Swap main view

useAppKitAccount

Composable function for accessing account data and connection status.

import { useAppKitAccount } from "@reown/appkit/vue";

export default Component(){
const accountData = useAppKitAccount()
}

Returns

  • accountData.address: The current account address
  • accountData.caipAddress: The current account address in CAIP format
  • accountData.isConnected: Boolean that indicates if the user is connected
  • accountData.status: The current connection status

useAppKitNetwork

Composable function for accessing network data and methods.

import { useAppKitNetwork } from "@reown/appkit/vue";

export default Component(){
const networkData = useAppKitNetwork()
}

Returns

  • networkData.caipNetwork: The current network object
  • networkData.caipNetworkId: The current network id in CAIP format
  • networkData.chainId: The current chain id
  • networkData.switchNetwork: Function to switch the network. Accepts a caipNetwork object as argument.

switchNetwork Usage

import { polygon } from '@reown/appkit/networks'

...

networkData.switchNetwork(polygon)
info

See how to import or create a networks here.

useAppKitState

Composable function for getting the current value of the modal's state.

import { useAppKitState } from '@reown/appkit/vue'

const stateData = useAppKitState()

Returns

  • stateData.open: Boolean that indicates if the modal is open
  • stateData.selectedNetworkId: The current chain id selected by the user

useAppKitTheme

Composable function for controlling the modal's theme.

import { useAppKitTheme } from '@reown/appkit/vue'
const themeAction = useAppKitTheme()
// or
// const { setThemeMode, setThemeVariables } = useAppKitTheme()

Returns

  • themeAction.themeMode: Get theme Mode.
  • themeAction.themeVariables: Get theme variables.
  • themeAction.setThemeMode: Set theme Mode. Accepts a string as parameter ('dark' | 'light')
  • themeAction.setThemeVariables: Set theme variables. Check the example usage.

Example Usage

setThemeMode('dark')


setThemeVariables({
'--w3m-color-mix': '#00BB7F',
'--w3m-color-mix-strength': 40
})

useAppKitEvents

Composable function for subscribing to modal events.

import { useAppKitEvents } from '@reown/appkit/vue'

const events = useAppKitEvents()

Returns

  • events.timestamp: Get the timestamp of the event
  • events.data.event: Get string of the event.
  • events.data.properties: get more information from the event.

useDisconnect

Composable function for disconnecting the session.

import { useDisconnect } from '@reown/appkit/vue'

const { disconnect } = useDisconnect()

disconnect()

useWalletInfo

Composable function for accessing wallet information.

import { useWalletInfo } from '@reown/appkit/vue'


export default Component(){
const { walletInfo } = useWalletInfo()
}

Ethereum/Solana Library

You can use Wagmi actions to sign messages, interact with smart contracts, and much more.

getAccount

Action for accessing account data and connection status.

import { getAccount } from '@wagmi/core'

const account = getAccount()

signMessage

Action for signing messages with connected account.

import { signMessage } from '@wagmi/core'

const signature = await signMessage({
message: 'gm wagmi frens'
})