# Check if connection is available

Components such as RUN and HTTP work by contacting the server program and retrieving the output value.

When the connection is not available, you may want to prevent the user from interacting with the app to avoid creating inconsistencies in your data.

# Preventing the App from Operating Offline

You can use a combination of the IF and ALERT components to check if there is an active connection and then alert the user, preventing any further operations.

Like this:



The conditions you can use in the IF component are the following:

  • server.connected to allow operations only when the app is connected to the server.
  • navigator.connection.type != 'wifi' to allow operations only when there is an active Wi-Fi connection. This ensures that the app still functions even if the server is not running.

Like this:



Then, by setting the Scan again label and leaving the other buttons label blank:



# Download Templates

Download: Check Connection.btpt Download: Check Wifi.btpt