---
title: "JavaScript SDK: Custom URL handler"
description: "Handle widget links with a custom URL handler with the Gleap JavaScript SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/414-javascript-sdk-custom-url-handler
collection: "JavaScript"
updated: 2026-11-01
language: en
---

# JavaScript SDK: Custom URL handler

Handle widget links with a custom URL handler with the Gleap JavaScript SDK. Follow the integration code examples.

There are scenarios where you need complete control over the behavior of hyperlink actions within your application. The method described below enables you to override the default URL handler. By setting a new URL handler, the Gleap framework will no longer manage URL openings automatically. Instead, it will invoke your custom callback function, giving you the freedom to handle URL interactions according to your specific requirements.

## Configure the URL handler

```javascript
Gleap.setUrlHandler((url) => {
  // Insert your URL handling logic here
  // Default: location.href = url;
});
```

## Related

- [JavaScript SDK setup](https://docs.gleap.ai/en/articles/393-javascript-sdk-setup.md)
- [JavaScript SDK: Code snippet](https://docs.gleap.ai/en/articles/394-javascript-sdk-code-snippet.md)
- [JavaScript SDK: User identity](https://docs.gleap.ai/en/articles/395-javascript-sdk-user-identity.md)
- [JavaScript SDK: Callbacks](https://docs.gleap.ai/en/articles/396-javascript-sdk-callbacks.md)
- [JavaScript SDK: AI chatbar](https://docs.gleap.ai/en/articles/397-javascript-sdk-ai-chatbar.md)
