JS Code - Events

Hello - I am new to retool & javascript so please bear with me.

I am trying to execute the following code off the click event of a button:

  try {
    console.log('Requesting any Bluetooth device...');
    const device = await navigator.bluetooth.requestDevice({
      acceptAllDevices: true

    console.log('> Requested ' + device.name + ' (' + device.id + ')');
  catch(error) {
    console.log('Argh! ' + error);

However, when it runs, I receive the following:

SecurityError: Failed to execute 'requestDevice' on 'Bluetooth': Must be handling a user gesture to show a permission request.

Does this fail because js code executes in a sandbox? If not, is there a way to address this or is there another way to handle this? The code is from this resource:

Thanks in advance for the help.

1 Like

Hey tjklug! We connected via intercom, but I wanted to follow up here as well. Unfortunately this is not currently possible in Retool. Though we tried several approaches we were blocked by some security surrounding running JS in Retool. We are always looking to improve our product, and will look into how we can ensure more and more external libraries and web services can be integrated!

Hi there -

Is this limitation still in place? I would very much like to utilize retool for a project involving Web Bluetooth.


Hey msd5079, yes this is still currently the case with JS in Retool. Due to security measures, I don't believe that this will be possible any time in the near future. Thanks for checking in!