---
updatedAt: 2026-04-13T17:22:37.000Z
agentTools:
  projectIndex: https://dev.superfans.io/llms.txt
---

# Open Custom Block

Opens a block built from the low code builder 

### Description

The `openCustomBlock` action opens a specific **custom block** within the Superfans app.\
Custom blocks are reusable, developer-defined UI components that extend app functionality — such as loyalty widgets, referral screens, or promotional experiences.  This action allows you to programmatically launch those blocks from anywhere in your app.

### Function SIgnature

```javascript
Superfans.actions.openCustomBlock({
		type: "full_screen",
		id:  "cbk_5das675asd765asd",
		params:{ productId } //optional
 //optional
})

// (OR)

Superfans.actions.openCustomBlock({
		type: "popup_bottom",
		id: "cbk_5das675asd765asd"
})

//(OR)

Superfans.actions.openCustomBlock({
		type: "popup_center",
		id:  "cbk_5das675asd765asd"
})
```

<Table align={["left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Parameter
      </th>

      <th>
        Type
      </th>

      <th>
        Required
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        type
      </td>

      <td>
        String
      </td>

      <td>
        yes
      </td>

      <td>
        The type of the custom block created.  
        values would be : full_screen, popup_center, popup_bottom
      </td>
    </tr>

    <tr>
      <td>
        id
      </td>

      <td>
        String
      </td>

      <td>
        yes
      </td>

      <td>
        The unique ID of the custom block created.
      </td>
    </tr>

    <tr>
      <td>
        params
      </td>

      <td>
        Object
      </td>

      <td>
        no
      </td>

      <td>
        This is optional parameter. You can pass any object like productID, CollectionID, etc.,
      </td>
    </tr>
  </tbody>
</Table>

### Retrieval of Block ID

Step 1: Navigate to the Custom Block section in the Superfans dashboard and select the custom block you want to open through code.

<Image align="center" src="https://files.readme.io/7383f87cd0d4a4627d4f240903a827c5abee9eff2ecf149f330ca9a52e78c4ec-Screenshot_2025-11-03_at_12.36.31_PM.png" />

Step 2: Copy the ID of the custom block which is the at the end of the URL after "/".

<Image align="center" src="https://files.readme.io/dda82f3877b88470b556063f5f82056ef2f1af87dd54e8284e57ccb0ad155dd7-Screenshot_2025-11-03_at_12.37.16_PM.png" />

### Structure of Response

| Status           | Response                                                                                                            |
| :--------------- | :------------------------------------------------------------------------------------------------------------------ |
| Success          | `{     "status": "success",     "message": "Custom block opened successfully"   }`                                  |
| Invalid Url      | `{     "status": "error",     "errorId": 400,     "errorHandle": "invalid-url",     "message": "Invalid url"   }`   |
| Unexpected Error | `{ "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" }` |

### Example Usage

```javascript
document.getElementById("ocb").addEventListener('click', () => {
Superfans.actions.openCustomBlock({
		type: "popup_bottom",
		id:  "cbk_0mshe0349jy0g"
})
});
```
```html
<div class="cart-container">
  <button class="open-cb-btn" id="ocb">Open Custom Block</button>
</div>
```
```css
.cart-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f0f0f0;
}
.open-cb-btn {
  background-color: #28a745;
  color: #fff;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.open-cb-btn:hover {
  background-color: #218838;
}
```

<br />

### Best Practices

1. Pass relevant data via props: Use props to send dynamic content (like user status or campaign IDs).
2. Combine with analytics: Track how often blocks are opened to measure feature engagement.
3. Graceful fallbacks: Always include error handling (.catch()) for unpublished or missing blocks.
4. Keep it lightweight: Avoid passing overly large data in props — use identifiers instead.

### Caveats

1. In-app context only: This action only works within the mobile app environment.
2. No automatic data refresh: Blocks won’t auto-fetch new data unless coded to do so.
3. Async execution: Always await or handle the Promise response to detect navigation completion.