Bubble Docs
  • Introduction
  • New? Start Here
  • What is Bubble?
  • The Glossary
  • User manual
    • Getting started
      • What is Bubble?
      • Building for...
        • Web
        • Native iOS and Android
          • Mobile app quick start guide
          • What is a native mobile app?
          • Native mobile vs. web development
          • Differences in native and web elements
          • Native mobile app terminology
      • Building your first app
        • Planning features
        • Database structure
        • Design and UX
        • eCommerce and payments
          • Shopping cart
          • Checkout page
          • One-time payments
          • Subscriptions
          • Marketplace
      • Creating and managing apps
      • The Bubble editor
        • Tabs and sections
          • Design tab
            • The element tree
            • The property editor
          • Workflow tab
          • Data tab
          • Styles tab
          • Plugins tab
          • Settings tab
            • Application settings
              • Custom headers/body
              • Visual settings
              • Social media sharing
              • Translating your app
              • Email settings
              • Collaboration
            • Custom domain and DNS
          • Logs tab
        • Tools
          • Key features
          • The search tool
          • The Issue Checker
          • The element tree
          • The element property editor
          • The debugger
          • Notes
        • Previewing your app
      • Transitioning to Bubble from...
        • JavaScript
        • HTML and CSS
        • SQL
    • Design
      • Elements
        • Web app
          • The page
          • Containers
            • Groups
            • Repeating groups
            • Table elements
            • Popups
            • Floating groups
            • Group focus
          • Visual elements
          • Input forms
            • Text and numbers
            • Dates and time
            • File uploads
            • Selection controls
        • iOS and Android app
          • The view
          • Containers
          • Visual elements
          • Input forms
          • Mobile reusable elements
        • The element hierarchy
          • The element tree
        • Reusable Elements
      • Styling
        • Color variables
        • Font variables
        • Styles
        • Custom Fonts
      • Responsive design
        • Building responsive pages
        • Legacy articles
          • The Basics (Legacy)
          • Building Responsive Pages (Legacy)
          • Migrating Legacy Pages
          • Tips When Designing (Legacy)
      • Templates
      • The Component Library
      • Importing from Figma
    • Data
      • The database
        • Data types and fields
        • Creating, saving and deleting data
        • Finding data
        • Displaying data
        • Protecting data with privacy rules
        • The database editor
        • Export/import data
          • Exporting data
          • Importing data (CSV)
        • Working with location data
        • Using Algolia
        • Database structure by app type
          • Marketplace Apps
          • Directory & Listings Apps
          • Social Network Apps
          • SaaS Apps
          • Project Management Apps
          • CRM Apps
          • Professional Services Apps
          • On-demand Apps
          • Documentation/ CMS Apps
          • Applicant Tracking System (ATS) Apps
          • Portfolio Apps
          • Gallery Apps
          • Online Store / Ecommerce Apps
          • Blog Apps
          • Messaging App
          • Dashboards
          • Building Block Apps
          • Bubble as a backend
      • Files
      • Images
      • Static data
        • App texts (translations)
        • Option sets
      • Temporary data
        • Custom states
        • URL parameters
      • User accounts
        • Authentication plugins
          • Facebook plugin
          • Fitbit plugin
          • Google plugin
          • Instagram plugin
          • LinkedIn plugin
          • Pinterest plugin
          • Slack plugin
          • Wistia plugin
          • YouTube plugin
        • Cookies set by Bubble
      • Time, dates and time zones
    • Logic
      • The frontend and backend
      • Workflows
        • Events
          • Frontend events
            • Recurring workflows
            • Custom events
          • Backend events
            • Database trigger events
        • Actions
        • API Workflows
      • Dynamic expressions
      • Conditions
      • Navigation
        • Single-page applications (SPA)
        • Multi-page applications
        • Page slugs
      • Device resources
        • Location services
        • Camera/photo library
    • Workload
      • Understanding workload
        • Activity types
        • The workload calculation
        • Client-side and server-side processing
      • Tracking workload
        • Measuring
          • Using App Metrics
        • Monitoring
          • Workload notifications
          • Infinite recursion protection
      • Optimizing workload
        • Optimization framework
        • Optimization checklist
          • Page load
          • Searches
          • Workflows and actions
          • Backend workflows
        • Agency showcases
          • Minimum Studio
          • Neam
          • Support Dept
    • Security
      • Bubble's security features
      • Planning app security
      • Client-side and server-side
      • Bubble account security
      • App security
      • Page security
      • Database security
      • API security
        • API Connector security
        • Data API security
        • Workflow API security
      • Flusk
        • Overview
        • Flusk plan features
        • Getting started with Flusk
        • Flusk security tools
          • The Issues Explorer
          • Issue details
          • Tools and settings
            • Pages rating
            • Database rating
        • Flusk FAQ
      • Cookies
      • Security checklist
    • Previewing your app
      • Previewing a web app
      • Previewing a mobile app
    • Publishing your app
      • Web app
      • Native mobile app
        • Global native mobile settings
        • iOS App Store
        • Google Play Store
        • Publishing FAQ
    • AI
      • Generate apps with AI
        • About AI app generation
      • AI page designer
      • Connect to AI agents
    • Maintenance
      • Collaborators
      • Version control
        • Best practices: Version control
        • Transitioning from the legacy version control
        • Terminology: Version control
        • Version Control (legacy)
      • Commenting
      • Database maintenance
        • Copying the database
        • Restoring database backups
        • Bulk operations
          • Bulk operation methods compared
        • Wiping change history
      • Performance
        • Hard limits
        • Capacity Usage (legacy)
        • Notes on queries
      • SEO
        • Introduction to SEO
        • SEO: App
        • SEO: Page
      • Testing and debugging
        • Introduction to testing and debugging
        • The debugger
        • The server logs
        • Supported browsers
      • API workflow scheduler
    • Integrations
      • API
        • Introduction to APIs
          • What is a RESTful API?
        • The Bubble API
          • Bubble API terminology
          • Authentication
            • How to authenticate
            • No authentication
            • As a User
            • As an admin
          • The Data API
            • Data API Privacy Rules
            • Data API endpoints
            • Data API requests
          • The Workflow API
            • Workflow API privacy rules
            • Workflow API endpoints
            • API workflows
              • Creating API workflows
              • Scheduling API workflows
              • Recursive API workflows
              • API Workflow Scheduler
              • Case: Stripe notifications
        • The API Connector
          • Authentication
          • API Connector security
          • API guides
            • OpenAI
              • Authentication
              • Calls
                • ChatGPT
                  • Chat
            • Google Translate
              • How to setup Google API keys
          • Streaming API
        • API security
        • Plugins that connect to APIs
        • API Glossary
      • Plugins
        • What Plugins Can Do
        • Installing and using Plugins
        • Authentication plugins
        • Special Plugins
      • SQL Database Connector
      • Bubble App Connector
      • WorkOS
        • WorkOS SSO
        • WorkOS API
    • Infrastructure
      • Sub-apps
      • Bubble release tiers
      • Hosting and scaling
        • How Bubble hosting works
        • Scaling with Bubble
        • CDN (Cloudflare)
        • Bubble app names
        • Domain and DNS
      • Compliance
        • GDPR
        • SOC 2 Type II
        • HIPAA
        • Other frameworks and standards
    • Bubble for Enterprise
      • Hosting and infrastructure
        • Dedicated instance
          • The Dedicated editor experience
          • Technical specs
          • Main cluster dependencies
          • Customizable options
          • Migration process
            • Pre-migration
            • During migration
            • Post-migration
      • Security and compliance
        • Single sign-on (SSO)
        • GDPR
        • SOC 2 Type II
        • HIPAA
        • Other frameworks
        • Bubble's security features
      • Admin and collaboration
      • Priority support
      • Billing and Payment Guideline for Dedicated Instances
  • Core Reference
    • Using the core reference
    • Bubble's Interface
      • Design tab
      • Design tab (Legacy)
      • Workflow tab
      • Data tab
      • Styles tab
      • Styles tab (Legacy)
      • Plugins tab
      • Settings tab
      • Logs tab
      • Template tab
      • Toolbar
      • Top and context menu options
      • Deployment and version control
        • Deployment & Version Control Dropdown (legacy)
      • Notes
    • Elements
      • Native mobile elements
        • View element
        • List component
      • General properties
      • General properties (Legacy)
      • Styling properties
      • Styling Properties (Legacy)
      • Responsive Properties
      • Responsive Properties (Legacy)
      • Conditional formatting
      • States
      • Page Element
        • Page Element (Legacy)
      • Visual Elements
      • Containers
      • Container Layout Types
      • Containers (Legacy)
      • Input Forms
      • Reusable Elements
      • Element Templates (legacy)
    • Workflows
    • Events
      • General events
      • Element events
      • Custom events
      • Recurring event
      • Database trigger event
    • Actions
      • Account
      • Navigation
      • Data (things)
      • Email
      • Element
      • Custom
    • On-device resources
    • Data
      • Data Sources
      • Operators and comparisons
      • Search
      • Privacy
    • Styles
    • API
      • The Bubble API
        • The Data API
          • Authentication
          • Data API endpoints
          • Data API requests
        • The Workflow API
      • The API Connector
        • Authentication
        • Adding calls
    • Bubble-made Plugins
      • AddtoAny Share Buttons
      • Airtable
      • API Connector
      • Blockspring
      • Box
      • Braintree
      • Bubble App Connector
      • Chart.js
      • Circle Music Player
      • Draggable Elements
      • Dropzone
      • Facebook
      • Fitbit
      • Full Calendar
      • Google
      • Google Analytics
      • Google Optimize
      • Google Places
      • Ionic Elements
      • iTunes
      • Slidebar Menu
      • LinkedIn
      • Localize Translation
      • Mixpanel
      • Mouse & Keyboard Interactions
      • Multiselect Dropdown
      • Progress Bar
      • Rich Text Editor
      • Rich Text Editor (Legacy)
      • Screenshotlayer
      • SelectPDF
      • Slack
      • Segment
      • Slick Slideshow
      • SQL Database Connector
      • Star Rating
      • Stripe
      • Tinder-like Element
      • Twitter
      • YouTube
      • Zapier
    • Application Settings
      • App plan
      • General
      • Domain / email
      • Languages
      • SEO / metatags
      • API
      • Collaboration
      • Sub-apps
      • Versions
  • Account & Marketplace
    • Account and billing
      • Pricing and plans
        • Plans and billing
        • Billing cycle
        • FAQ: Pricing and Workload
      • Account Management
      • Building Apps for Others
      • Selling on the Marketplace
      • Plans & Billing (legacy)
    • Official Bubble Certification
      • Hiring certified developers
    • Building Plugins
      • The Plugin Editor
      • General Settings
      • Updating to Plugin API v4
      • Adding API Connections
      • Building Elements
      • Building Actions
      • Loading Data
      • Publishing and versioning
      • Github Integration
    • Building Templates
    • Application and data ownership
    • Marketplace policies
    • Bug reports
  • Vulnerability Disclosure Policy
  • Beta features
    • About the Beta features section
    • Native mobile apps
Powered by GitBook
On this page
  • Element events
  • Example: Button click
  • Example: Input value changed
  • Example: catching errors
  • General events
  • Example: Conditional expression

Was this helpful?

  1. User manual
  2. Logic
  3. Workflows
  4. Events

Frontend events

The section covers frontend events, which are the events that are triggered on a page.

Last updated 1 month ago

Was this helpful?

Frontend events are the triggers that happen on a page. It's often – but not always – initiated by a user. Frontend events will only trigger as long as the page is open.

Frontend events can still lead to actions happening on the server – but the event (or trigger) happens on the page.

Element events

One of the first and most basic types of triggers are the result of actions taken by the users of your app directly by interacting with an element. For example, a user could click the Submit or Save button in order to start a sequence of actions that saves the values the user has provided in the database.

Element events include:

  • Button/icon/other element clicked

  • values being updated

  • An element

Adding more elements (and elements from plugins) can add to the list of possible element events.

Example: Button click

Let's first have a look at one of the most fundamental events an app can have: responding to the click of a button.

  1. First, we'll add an element of the type Button to the page. In the example below, we have labelled it Sign up.

  2. Then, right-click the button to see the contextual menu, and select Start/edit workflow.

You will be taken to the workflow canvas and the newly created workflow, and can start adding actions to it by clicking the + icon.

Example: Input value changed

In the next example, we'll look at how you can set up a workflow to run whenever the user changes the value provided in an input form. Changes are registered in two different ways:

  • Text-based elements: Whenever the element loses focus

  • Click-based elements (such as dropdowns and calendars): Whenever the user confirms their choice with a click

  1. We'll start again with adding an element. Pick one of the elements in the Input form category; we're going with a regular text input element.

  2. Again, we can right-click the element to automatically create a workflow. Bubble will recognize the element type and automatically set the event to respond to the element's value being updated

Again you will be taken to the workflow canvas and there will be a new workflow automatically labelled by the event:

You can then proceed to add the needed actions in response the input's value being changed.

To automatically save changes to the database when an input form's value is changed, you can also use auto-binding. This will save the value without the need to set up a workflow.

Example: catching errors

Sometimes, trying to run a workflow in Bubble will result in an error. For example, a user might be trying to log in, but provide the wrong credentials. In this case, Bubble will by default alert the user in a browser-standard message:

The An element hits an error event is connected to the workflow that triggered the event. In other words, if the user entered the wrong password, the Log in button is the trigger – not the input field, since the button is the one that triggers the workflow where the error happened.

We want to show an alert that we are free to style as we want, so let's first add an Alert element to the page and set it to appear at the top of the page:

Then, we'll create the event/workflow. This time we'll need to create it in the workflow canvas:

  1. Click the plus symbol in the Uncategorized folder (or any folder where you would like to add the workflow). The new event menu will automatically be displayed.

  2. Then, add the An element has an error running a workflow action and pick the Log in button

Now we have the event set up to trigger every time a workflow initiated by the Log in button leads to an error. Let's set it up to show the alert and use Bubble's original error message:

Identifying and changing error messages

In the example above, we are using the system generated error message found in the Current workflow error data source.

The message operator will show the message that Bubble would otherwise have displayed in a standard error message. The code is used to identify the error. If you want a particular action to run on a certain error for example, you can use the only when field to set up a constraint that checks the error code.

Identifying codes and changing messages

All of Bubble's built-in messages are stored in that you will find by navigating to Settings - Language.

The code of the error message is visible as grey, all-caps text under each text descriptor. On the right side you can edit the error message that will be displayed. This will replace the message regardless of whether you are showing it with a workflow or the default browser error message.

General events

General events are events that are triggered by something happening on the page that is not directly related to an element. It's not necessarily (but can be) the result of a user action:

When the page is loaded or URL refreshed

Whenever the page is loaded or the URL refreshed (such as adding URL parameters) with the action, this event will trigger. This is useful for things that need to happen immediately whenever a user loads the page.

Keep in mind that as the Go to page action will trigger this even if the page is not technically reloaded, you may end up triggering it more times than you intended. Use a condition to avoid this.

The user is logged in or out

This event will trigger whenever the user's login status changes and is useful for redirecting users that are logged out for example. It will also trigger on page load according to the login status you provide, meaning that if you instruct Bubble to go to another page if the user is logged out, that event will immediately trigger when the user tries to load the page.

Note that the Log out user's other sessions launched from another device may not trigger the event immediately, but will trigger it once the user takes some further action on the page.

An unhandled error occurs

This event in principle does the same as the above-mentioned An element hits an error, but applies more broadly: any error, regardless of the element (if any) that caused it, will trigger it and allow you to run some actions in response. This is useful if the response you want is an error message for example; by not binding it to a specific element, you can catch all errors in one event.

When a condition is true

Triggering an event when a condition is true uses conditional expressions to check whether something is true or false in real-time. This is a powerful feature that lets you set up logical rules that trigger a workflow instantly whenever the expression returns a yes.

Example: Conditional expression

Let's use the When a condition is true event combined with a conditional expression to make something happen. This time, instead of logging in, we'll change it to signing up: when the user has provided both an email and a password, we'll animate the Sign up button to encourage the user to click it.

Add two input fields (for email and password) and a button for signing up. Make sure you set the Content format on each of the fields to Email and Password respectively. Then, we'll set up the event to catch it. We don't only want the input fields to not be empty; we want them to be valid.

First, add the workflow, and Bubble will ask for an event. You'll find this under General:

Then, we'll set up the expression that checks the input fields:

  1. We're fine with the animation appearing just once, so we'll leave the Run this dropdown set at Just once.

  2. In the expression we are checking both inputs, and using an and operator to make sure that both inputs need to be valid, as opposed to just one (in which case we would have used the or operator). We need to check four things in this expression to make it work the way we want:

    1. Input Email's value must not be empty (meaning it must contain text)

    2. Input Email must be valid (meaning it must be a valid email)

    3. Input Password's value must not be empty

    4. Input Password must be valid (technically, all passwords are valid, but you can choose to set a required password strength for example)

  3. We then use the Animate an element to animate the button. We chose the subtle Callout pulse animation for this

Article section:

System errors will result in a standard error message like this in Chrome, but you can override that message by setting up an event to catch it. Click the image to enlarge.
Checking the Position the alert at the top box lets us stick the alert to the top of the screen regardless of scrolling position.
Auto-binding