Setup
To get started, install the Median Bubble plugin in the Bubble app editor via Plugins → Add Plugins → Median Plugin. Drag the “Median Plugin” element from the “Elements” section and drop it on the page that requires access to the Median JavaScript Bridge. This element initializes the JavaScript Bridge library so that commands can be executed on page load as shown in the following section. Median JavaScript Bridge Plugin on BubbleDeveloper DemoDisplay our demo page in your app to test during development Demo Bubble app
Execute command on page load
To execute a Median JavaScript Bridge command on page load, click the “Median Plugin” element that you just dropped on the page and insert your desired JavaScript into the text input captioned “Median Library Ready Custom Script” as shown below:
Median on page load JavaScript
Execute command as a workflow/action
Suppose you want to set the device brightness to 80% when a user taps a button. To accomplish this, drag a button from the “Elements” section on your page and change its name to “Set Brightness” or as desired:
Create a button

Create a new workflow

Select action

Set brightness
Dynamic value
You can also assign a dynamic value to the brightness field so that it takes the value of an element as its input. The dynamic value can be a text input, a slider, or any one of the elements from which a value can be read. For instance, to set the dynamic value as a slider value, drag and drop a “Slider Input” element from the “Elements” section to your page. Since the acceptable brightness values in Median apps are between 0 and 1, set the min and max values of the slider element to 0 and 1 respectively, and set the “Step” to 0.1 as shown below:
Slider config

Slider value changed event

Slider dynamic data

Slider action
Execute custom JavaScript
To access advanced Median JavaScript Bridge functions in a custom script, you can use any plugin that enables JavaScript execution. For instance, you can run any Median JavaScript commands via the “Toolbox plugin” which allows you to run JavaScript as a workflow. Once the plugin is installed, select an element and click “Start/Edit workflow”. Create an action, choose Plugins → Run JavaScript, and add your desired JavaScript to run as shown below:
Toolbox JavaScript
Process returned data
Returned data variableAll the data that Median returns from the app can be accessed in your custom callback script by the variable named “data”.For example:
median.contacts.getAll(). This function returns a JSON object containing the user’s contact list that you can send to your server via AJAX calls or pass to one of Bubble’s elements such as the “Multiline Input” as seen in the following example.
First, you will need to enable the ID Attribute in your elements by going to Settings → General and checking the option “Expose the option to add an ID attribute to HTML elements”. Now, drag the multiline input element to your page, double-click it and set its ID Attribute (at the very bottom) to a unique string (such as contacts_output).
Note: Since this ID Attribute will be used to identify a unique element in a given page, it has to be a unique string.
Once complete, go to your Workflow section, then open the “Median Native Contacts” action you want to read the data from, and paste the custom callback script as shown below. Replace contacts_output with the ID Attribute of your multiline input element. This script will set the value of the element with the ID Attribute contacts_output (in our case, the Multiline Input) to the “stringified” JSON object that the Native Contacts plugin returned.

Median Native Contacts: ID Attribute
Supported commands
The following JavaScript Bridge commands are supported within the Bubble plugin via drag-and-drop actions:- Set Screen Brightness
- Set Status Bar
- Download file / image
- Share Page
- QR / Barcode Scanner
- Device Info
- Set Navigation Titles
- Set Sidebar Items
- Set Tab bar Items
- Set Navigation Levels
- OneSignal Info and Set / Remove External User ID
- OneSignal Show Tags UI
- Native Contacts
- Firebase Analytics - Set User and Log Events
- Send Facebook Events
- iOS ATT consent Request / Get Status
- Show/Hide iOS Contextual Navigation Toolbar
- Social Login Server-side Redirect functions
- Social Login JavaScript Callback functions