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 need | Recommended mode | Code to write |
|---|---|---|
| Fastest integration, no layout changes | Default Mode | Least |
| A purchase button at a specific spot (e.g. below the price) | Button Mode | Little |
| A banner at a specific spot on the page | Banner Mode | Little |
| Your own button, fully styled by you | Custom Mode | A 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.
<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>2. Button Mode: A Purchase Button Where You Choose
Put an empty div on the page, and the SDK shows the purchase button there.
<!-- 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>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.
<!-- 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>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.
<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>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:
rakufun.enableDebug(); // Shows the interface with a DEBUG badge in the top-right corner. Remember to remove it after testingShowing 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.
rakufun.setUICartHandler(async (product) => {
return confirm(`Confirm purchase of ${product.title}?`);
});Questions? Contact us: service@rakufun.com