# Supabase Data

{% hint style="info" %}
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.&#x20;
{% endhint %}

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.&#x20;

{% hint style="warning" %}
Please note, this will always take Role Level Security into account.
{% endhint %}

In order to use the plugin which is tailored to your Database there's a few things needed to do:&#x20;

* 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".

<figure><img src="/files/JxFaHHFTQaF1IoQ5jkSj" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
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.&#x20;
{% endhint %}

* Copy the cURL into the API Connector, the call should look like this:&#x20;

<figure><img src="/files/pJ7Cq7D1I0bQqYgFUXhl" alt=""><figcaption></figcaption></figure>

* 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. <br>

  <figure><img src="/files/9eoZvxiECgf8v8Z0bFQO" alt=""><figcaption></figcaption></figure>
* 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.&#x20;

<figure><img src="/files/MXUtN6Tk5pf9PJIB35Nn" alt=""><figcaption></figcaption></figure>

When successful your Data is ready to be used in Repeating groups, like in the screenshot below.&#x20;

<figure><img src="/files/OEpXNtc1T1E2c1p7eDiH" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.relevat.hu/supabase.js-bubble-plugin/setup/supabase-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
