How to create Supabase admin dashboard?
Tags: webdev, supabase, lowcode
Published: 2024-02-13 14:36:07

In this article, the database meets ui!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3h4u3c6i0om0w589dnqz.gif)

You will find how to build an Admin Dashboard on top of Supabase using [UI Bakery](https://uibakery.io/):

1. Connect Supabase to UI Bakery
2. View Supabase data
3. Add form to edit records
4. Publish an app to make it available for your users

[Supabase](https://supabase.com/) is an open-source Firebase alternative. It’s built on top of PostgreSQL and stuffed with many features such as database, auth, storage, REST, and GraphQL APIs. Everything is backed in a modern intuitive no-code UI. All that makes it a good choice for your database while [UI Bakery](https://uibakery.io/) will focus on the UI.

In this tutorial, I’ll show you how to create an admin panel for your supabase database using [UI Bakery](https://uibakery.io/). Here is what we’ll build - an admin panel that can view data from the database and provides a user-friendly interface for records editing:

<img src="https://i.ibb.co/gtBQrdL/1-what-we-ll-build.gif"></img>

---

If you prefer video content, here’s my video explaining how to make a supabase admin.

{% embed https://youtu.be/ul45AXxEZb8 %}

---

## Connect supabase to UI Bakery

First things first, let’s connect the supabase db to UI Bakery.

Open your supabase project, go to the “Project Settings” → “Database”. Here in the “Connection parameters” section, you’ll find the database credentials required for connection:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hjoh0ihfj50x6dflzos.png)

Now, in your [UI Bakery](https://uibakery.io/) workspace, go to “Data Sources” → “Connect”. In the connection form, fill in the credentials copied from the “Connection parameters” section of the database settings.

Press “Connect Datasource” and supabase integration is done. Now we can build an actual application.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ut9x48goyht6efzjhcaq.png)


---

## View supabase data

In the UI Bakery workspace, click “Create app” → “Create new app”, fill in the application name, and click “Create app”.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91w09q9it92q0a91zg4p.png)

Now you’re in an application builder. Here you can see 3 major panels:
- Left - components list, here you will find components to add to the screen.
- Right - Selected component configuration where you change component properties.
- Bottom - actions panel - all the application logic lives here.

Let's focus on data first - create a new action that will load data from the connected supabase db. In the **actions panel** click “Create action”, choose your supabase database connected before, then “Load table” and finally choose a table to load. When configuration is done click “Execute action” to preview the data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hw3gwhnqbw5o8spk0s8q.png)


When data is loaded in UI Bakery we can start building UI. First of all, let's add a table to view records. Find the Table in the components panel, then drag-drop it on the working area.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64rapvcqhy06fjovqpqc.png)

Using the component settings panel configure what columns are displayed and change the title of the table:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fr7eq03ygujrrcwfcz9t.png)

At this stage, you have an application that loads data from the supabase database and displays it inside a good-looking table. Now it’s time to focus on records editing.

---

## Add form to edit records

Drag’n’drop a **form** component from the **components** panel to the working area to the right of the table. When a component is in its place we have to configure it to display data from the **selected row** of the table.
Locate the **Data** field in the “Component settings” sidebar and reference the table’s selected row data using variable syntax - `{{ui.clientsTable.selectedRow.data}}`. Curly braces allow using variables in components settings fields. **`{{ui`** - means we’re referencing UI component from the workspace. **`{{ui.clientsTable`** - means we’re referencing a component called “clientsTable”, and **`{{ui.clientsTable.selectedRow.data}}`** means to get the data from the selected row of our table.

When the **Data** field is set, hit the “Regenerate structure” button and the form will apply the referenced table structure to itself so you don’t have to configure the form structure. It will just be the same as in your table.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yd0o6jm600p0486qs6gc.png)

To make this form update records in the database you have to scroll the “component settings” panel to the bottom and find the “Triggers” section. There hit “Add trigger”, select “On Submit” to trigger the action when the form is submitted, and click “Create action” to add a new action assigned to the “On Submit” trigger.

At the “Actions” panel a new empty action appears. In the opened popup select your supabase database we connected before → “update Row” → supabase table to update.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j97nlvdzubrlgclbfch3.png)

After that, we should configure an update behavior. In “Configure filter to update record(s)” type *`{{ui.clientForm.value.id}}` -* reference an **ID** of the record in the form.

Then, to the right of the “Configure record fields to update” field, click on the “JS” button:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jcz65jf8ad6e0gnr5iut.png)

This will turn the form into a code field, so we can just reference the whole form value using variable syntax `{{ui.clientForm.value}}`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knyjn1ygv5g9c374s7br.png)

So this action does the following - it will find all the records with IDs equal to the entity ID and update all the fields changed in the form.

The last step we have to perform here is to reload data in the table.

Create a new action step below the “update” step, choose “Execute action” and in the “Action to execute” field choose the “loadClients” action. This configuration will trigger the “loadClients” action right after the database record is updated. So we’ll always have fresh data in the table.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2wtnvg4thnw1zbupspu.png)

---

## Publish an app to make it available for your users

Finally, to make an application available for your users you have to publish it. Click the “Release” button at the top right corner and hit “Publish release”.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkf5c9x4iw9677orazof.png)

Now your supabase application is up and running! The only thing left to do is invite your users.
In the workspace, click on your email → “Users & Permissions”. There you’ll be able to invite your teammates to collaborate in your app.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbrkjxstak6689y5do8a.png)

Now you have a neat-looking supabase admin panel where you can view and edit your data.

Using UI Bakery builder you can add other features to your app, protect them using roles and permissions, adapt an app for mobile devices, customize the look and feel of your application using a theme editor, and many many more.

All of that in a fraction of a minute.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lrvj3s1f6qdiq5zyyd1.gif)

[Join UI Bakery community](https://cloud.uibakery.io/auth/register) and build applications in minutes - not months!