Bando Docs
Launch AppLearn More
  • Bando for Developers
    • The On-chain Spending Protocol
    • Quickstart
    • Glossary
    • Use Cases
    • Protocol Architecture
      • Payment Reference Validation
      • Order Request
      • Order Fulfillment
      • Refunds
  • Spending Widget
    • Widget Quick Start
    • Installation
    • Configuration
    • Customization
    • Localization
    • Wallet Management
    • Framework Integration
      • Next.js
      • Svelte
  • Fulfiller API
    • Get Started with the API
    • Authentication
    • Guides
      • Get Available Products
      • Get a Payment Reference
      • Validate a payment reference
      • Get a Quote
      • Get Available Tokens for a Chain
    • API Reference
  • EVM Smart Contracts
    • EVM Smart Contracts | Architecture
    • Contracts
      • Core
        • BandoERC20Fulfillable
        • BandoFulfillmentManager
        • BandoFulfillable
        • BandoRouter
        • FulfillmentTypes
      • Libraries
        • FulfillmentRequestLib
        • SwapLib
      • Periphery
        • ERC20TokenRegistry
        • FulfillableRegistry
      • Proxy
        • Upgradeability
    • Security
      • Access Control
      • Security Considerations
      • Rekt Test
      • Audits
    • Code
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Spending Widget
  2. Framework Integration

Svelte

Configure the Bando Widget in Svelte.

To use the Bando Widget with Svelte, you can follow these steps:

<script lang="ts">
import { createElement } from 'react'
import type { Root } from 'react-dom/client'
import { createRoot } from 'react-dom/client'
import { onDestroy, onMount } from 'svelte'

let container: HTMLDivElement
let root: Root

onMount(() => {
  const { element, children, class: _, ...props } = $$props
  try {
    root = createRoot(container)
    root.render(createElement(element, props, children))
  } catch (e) {
    console.warn('ReactAdapter failed to mount.', e)
  }
})

onDestroy(() => {
  try {
    root.unmount()
  } catch (e) {
    console.warn('ReactAdapter failed to unmount.', e)
  }
})
</script>

<div bind:this={container} class={$$props.class} />
<script>
import { BandoWidget } from '@bandohq/widget'
import ReactAdapter from './ReactAdapter.svelte'
</script>

<ReactAdapter
  element={BandoWidget}
  config={{
    theme: {
      container: {
        boxShadow: '0px 8px 32px rgba(0, 0, 0, 0.08)',
        borderRadius: '16px',
      },
    },
  }}
  integrator="svelte-example"
/>

<style>
  /**
   * Styling a React Component from within a Svelte Component.
   */
</style>
<script lang="ts">
import BandoWidget from './lib/BandoWidget.svelte'
</script>

<BandoWidget />

<style>
</style>
PreviousNext.jsNextGet Started with the API

Last updated 6 months ago

Was this helpful?