Create widget session
Creates a widget session on your backend to pre-configure the Pay or Deposit / Withdrawal widget — the mode, amount, allowed chains, and funding sources. Pass the returned id to the widget on your frontend.
Import
import { createWidgetSession } from "@paywithglide/glide-js";Usage
import { createWidgetSession } from "@paywithglide/glide-js";
import { config } from "./config";
const { id } = await createWidgetSession(config, {
mode: "pay",
amount: "5",
});
// Pass `id` to the useGlidePay hook on your frontendParameters
The widget mode the session is for.
The amount, denominated in your preferred currency configured in the Glide Dashboard.
The wallet address that receives the funds.
The chains the user can pay from. Defaults to the chains set in the config.
The funding sources to offer: wallet, external_wallet, transfer, coinbase, coinbase_app, fiat, interac, onramp, or onramper.
Chains to exclude from the payment options.
Currency tiers to exclude from the payment options.
Funding sources to exclude: transfer, coinbase, coinbase_app, fiat, interac, onramp, or onramper.
Custom string metadata to attach to the session.
Commission rates per currency tier (tier1, tier2, tier3) paid out to the developer, as a percentage of the transaction amount (e.g., "0.5" = 0.5%).
The maximum destination-chain gas fee, in USD, that will be sponsored.
When set to true, the payer will receive an email if their payment is refunded.
The email address of the payer, used for refund notifications.
The phone number of the user.
An identifier for generating a stable deposit address across sessions.
Return Type
Returns a widget session object:
The unique identifier of the widget session. Pass this to the widget on your frontend.
The widget mode.
The metadata attached to the session.
The widget session also echoes back the configuration it was created with (chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, commissionRates, maxSponsoredGasFeeUSD, stableDepositAddressKey, widgetConfig).