Supabase Data
Last updated
Last updated
It's a good practice if your Data rely on the User being authenticated that you hide all the Data elements until the Auth has been successfully Initialized. This can be done with a condition to only show the Data elements once: "Supabase Auth's Access Token is not empty". Since this token will only appear when the user is authenticated and the code inside the Data element will only run once visible on the page.
The Supabase Data element is the core element of the Plugin. On page load it fetches the information based on your input which you can access right away. When you Create, Update or Delete Data, it will automaticaly refreshes the originally fetched list.
Please note, this will always take Role Level Security into account.
In order to use the plugin which is tailored to your Database there's a few things needed to do:
Let's say you have a table called "Books" if you'd like to access the data, first we have to make it available in Bubble as a Data Source. Head over to the API Documentation and copy the cURL for "Read rows".
As you can see we use the 'service_role' key when we copy this cURL. However it's safe, since we're using the API Connector to initiate this API call. The plugin itself won't use the 'service_key' for any of the calls.
Copy the cURL into the API Connector, the call should look like this:
Once you click Initialize call, you should see the Returned Values. Make sure you check all the things, make sure it's the right format. Like in the below example we've changed the "created_at" field from text to date, so we can use as a date in Bubble.
For the Plugin element the setup should be the following. Make sure for the "Table" and "Filter Name" you set the values exactly how it's in your Supabase Instance.
When successful your Data is ready to be used in Repeating groups, like in the screenshot below.