> For the complete documentation index, see [llms.txt](https://devdocs.joy.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devdocs.joy.so/joy-javascript-api/joy-loyalty-sdk/widget-methods.md).

# Widget methods

### Open widget

You can manually trigger the opening of the Joy floating widget with this method:

```javascript
joyInstance.openWidget()
```

### Close widget

You can manually trigger the close of the Joy floating widget with this method:

```javascript
joyInstance.closeWidget()
```

### Reload customer data

If you issue or redeem points using the API or Joy SDK and want other widgets or the loyalty page to refresh the customer’s balance and tier in real time, you can trigger a reload by calling:

```javascript
window.joyInstance.updateCustomerState()
```

### Open page

You can use this method to open a targeted page on the floating widget.

```javascript
joyInstance.openPage(page)
//View below for possible values
```

All possible values for the page would be:

| Page value    | Page description                         |
| ------------- | ---------------------------------------- |
| `home`        | The home page the widget                 |
| `howToEarn`   | The earning program list of the widget   |
| `howToRedeem` | The redeeming program list of the widget |
| `milestoneV2` | The milestone rewards page of the widget |
| `activities`  | The point history page of the widget     |
| `rewards`     | The coupon list page of the widget       |

### Open to a redeeming program

You can get the list of the redeeming programs available and then use the program ID to open:

```javascript
joyInstance.openRedeemProgram(programId)
```

### Register a custom handler for redirecting guests to the login

Register a custom callback to control how guests are redirected when they try to access loyalty actions. This lets you override the default redirect and send guests to your own login or signup flow.

```javascript
window.addEventListener('joy:ready', () => {
    // Register the callback to handle guest redirects
    window.joyInstance.registerRedirectGuest((type, redirectUrl) => {
      // Your own code your simple to test: return alert('Need to login');
    });

    console.log('Guest redirect callback registered successfully');
  });
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://devdocs.joy.so/joy-javascript-api/joy-loyalty-sdk/widget-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
