Skip to content

UI Modes Overview ​

The UI mode decides what the RAKUFUN purchase entry looks like on your page and where it goes. There are four; just pick one.

How to Choose ​

What you needRecommended modeCode to write
Fastest integration, no layout changesDefault ModeLeast
A purchase button at a specific spot (e.g. below the price)Button ModeLittle
A banner at a specific spot on the pageBanner ModeLittle
Your own button, fully styled by youCustom ModeA bit more

If you're not sure, start with the default mode.

In the first three modes the interface is provided by the SDK, and you only need to give it the product information. Custom mode doesn't use the SDK's interface; you make the purchase button yourself.

Live Demo ​

Switch between the three interfaces provided by the SDK (default, button, banner) below:

🎨 实时 UI 模式切换演示

在下方选择一个模式,即可实时查看 UI 渲染效果

模式控制:
状态:模式: 未选择 | 已挂载: false
按钮容器

在 button 模式下激活

横幅容器

在 banner 模式下激活

💡 提示:在 default 模式下,底部面板出现在页面底部。 在 button 和 banner 模式下,组件会渲染到上方的容器中。

The Four Modes at a Glance ​

1. Default Mode: A Purchase Panel at the Bottom of the Page ​

A purchase panel appears at the bottom of the page automatically, no changes to your page structure. After including the SDK, just tell it which product this is.

html
<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
<script>
  rakufun.setUIProductData({
    url: window.location.href,
    title: 'Product Name',
    price: '12800',
    images: ['https://example.com/product.jpg']
  });
</script>

View Details →


2. Button Mode: A Purchase Button Where You Choose ​

Put an empty div on the page, and the SDK shows the purchase button there.

html
<!-- The button appears here -->
<div class="rakufun-sdk-embed-button"></div>

<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
<script>
  rakufun.setUIMode('button');
  rakufun.setUIProductData({
    url: window.location.href,
    title: 'Product Name',
    price: '12800',
    images: ['https://example.com/product.jpg']
  });
</script>

View Details →


3. Banner Mode: A Banner Where You Choose ​

Used the same way as button mode, but it shows a banner. Clicking anywhere on the banner starts the purchase.

html
<!-- The banner appears here -->
<div class="rakufun-sdk-embed-banner"></div>

<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
<script>
  rakufun.setUIMode('banner');
  rakufun.setUIProductData({
    url: window.location.href,
    title: 'Product Name',
    price: '12800',
    images: ['https://example.com/product.jpg']
  });
</script>

View Details →


4. Custom Mode: Use Your Own Button ​

Doesn't use the SDK's interface. First turn off the SDK's bottom panel with disableAutoUI(), then call quickBuy() when the user clicks your button.

html
<button id="my-button">Buy Now</button>

<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
<script>
  rakufun.disableAutoUI(); // Don't show the SDK's bottom panel
  document.getElementById('my-button').onclick = async () => {
    const result = await rakufun.quickBuy({
      url: window.location.href,
      title: 'Product Name',
      price: '12800',
      images: ['https://example.com/product.jpg']
    });
    if (!result.success) console.error(result.message);
  };
</script>

View Details →


Additional Notes ​

Can't see the interface when testing from Japan ​

For Japanese IPs, the SDK hides its interface by default (in the default, button, and banner modes). When testing from Japan, you can temporarily add:

javascript
rakufun.enableDebug(); // Shows the interface with a DEBUG badge in the top-right corner. Remember to remove it after testing

Showing a confirmation dialog after the click (button and banner modes only) ​

Use setUICartHandler. The purchase continues only if the function returns true; any other value cancels it. This setting has no effect in the default mode.

javascript
rakufun.setUICartHandler(async (product) => {
  return confirm(`Confirm purchase of ${product.title}?`);
});

Questions? Contact us: service@rakufun.com

Released under the MIT License