> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom JavaScript

> Inject custom JavaScript into your website in the app.

JavaScript added via the configuration panel is automatically injected into both iOS and Android versions of your app. You can also apply platform-specific scripts when needed.

> [!TIP]
>
> **Use your AI agent**
>
> Use the Median MCP with your AI agent to replace your app's custom JavaScript. See
> [Median MCP server](https://docs.median.co/docs/mcp-server.md) to set it up.
>
> The MCP can't read your current JavaScript, so give your agent the complete script you want.

## Injecting JavaScript without `<script>` tags

JavaScript should be written exactly as it would appear in a standalone `.js` file. Do not include HTML tags like `<script>`. The code will automatically be executed when your site loads in the app.

## Example: Send [device info](https://docs.median.co/docs/device-info.md) on your login page

Use the Median JavaScript Bridge to access device information and send it to your server, such as during sign-in or registration flows:

```javascript JavaScript theme={null}
/* This script checks if the current page path starts with /login and then calls median.deviceInfo() to retrieve device details. It sends that data to your server via a POST request. */

if (location.pathname.startsWith('/login')) {
median.deviceInfo().then(function (deviceInfo) {
  fetch('https://yourwebsite.com/api/registration', {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(deviceInfo),
  });
});
}

```


## Related topics

- [Bubble plugin](https://docs.median.co/docs/bubble-plugin.md)
- [Website overrides overview](https://docs.median.co/docs/website-overrides-overview.md)
- [Install Median's GTM tag template](https://docs.median.co/docs/install-median-gtm-template.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.