Skip to content

useGlyphView

A hook that allows developers to control the widget view programmatically.

Description

The useGlyphView hook provides access to the widget view control functionality. It returns a function that can be used to update the current view of the widget.

Usage

tsx
import { GlyphView, useGlyphView } from "@use-glyph/sdk-react";

function MyComponent() {
	const { setGlyphView } = useGlyphView();

	const onBtnClick = () => {
		// open "Fund" view of the Glyph widget
		setGlyphView(GlyphView.FUND);
	};

	return <button onClick={onBtnClick}>Fund Glyph wallet</button>;
}

API

Returns

PropertyTypeDescription
setGlyphView(view: GlyphView) => voidFunction to update the current widget view

Available views

  • GlyphView.MAIN: The home of the Glyph wallet, with balance and buttons to send, receive, add funds, etc. Same as GlyphView.MAIN and GlyphView.OPEN.
  • GlyphView.TOKENS: List of owned token balances.
  • GlyphView.ACTIVITY: List of transactions fired from the widget (e.g. fund, send).
  • GlyphView.FUND: Initial form to input amount to fund in user's local currency.
  • GlyphView.SEND: Form to send tokens to another user.
  • GlyphView.RECEIVE: Displays user's address in plain text (with its copy button) and encoded as QR code.
  • GlyphView.PROFILE: Displays user's profile information. Only available for users logged in with Glyph cross-app account.
  • GlyphView.LINKED_ACCOUNTS: Linked accounts view. Only available for users logged in with Glyph cross-app account.
  • GlyphView.CLOSED: Closes the wallet view, if open.

Notes

  • This hook must be used within a component that is wrapped by GlyphProvider (or GlyphPrivyProvider and GlyphWalletProvider).
  • If used outside one of the providers, it will throw an error.