BrainBite logo
BrainBite
Contact

What is Supabase? and Its implementation in node.js?

Quick overview of supabase and how you can connect your supabase using node.js.

3 min read

Hii 👋

supabase

Let's first introduce " supabase? "

Supabase a complete back end for web and mobile applications based entirely on free open source software. The biggest challenge when building an app is not writing code but rather architecting a complete system that works at scale. Products like Firebase and Amplify have addressed this barrier but there's one big problem they lock you into proprietary technology on a specific Cloud platform. Supabase is solved this problem.

Supabase was created in 2019 specifically as an open source.

Supabase can listen to data changes in real-time. You can create tables in your PostgreSQL database with a click of a button, insert columns to build out your schema, then add new rows to populate it with data. Supabase is easy to use. Read the full blog to learn "how to implement of Supabase in your project?".

Create new project or you can use older one also.

Install supabase package:

npm install @supabase/supabase-js

If you encounter errors while running your project, try installing these additional packages:

npm install bufferutil utf-8-validate

Get supabaseURl and supabaseKey:

  • 1.) Login to your supabase account.

  • 2.)Create new project: Enter your project name. You can generate a strong password or add your own. Then, just click on "Create New Project".

Create new project on Supabase
  • 3.)Copy URL and key: From the left menu, go to "Home". Then scroll down a bit. You will see a "Project API" on your screen. Just copy the "Project URL" and "API Key". You might see some other keys that are not required as of now.
Supabase Api & Key

Connect Supabase db:

import { createClient } from "@supabase/supabase-js";
const supabase = createClient("url", "key"); // Pasted your url and key to build a connection 

Now you successfully connected with your Supabase.

Create table

Create a table in our project where we can store our data.

Create new table

While creating the table, make sure both checkboxes are disabled. If you want to enable RLS (Row-Level Security), then before accessing the data, you have to create a policy.

Creating table

Insert data into Supabase:

const { data, error } = await supabase
    .from("emails") //your table name
    .insert([{ email: "xyz@gmail.com" }]) // column "email" where you want to store the data.
    .select();
if (error) {
    console.log("Error inserting data");
} else {
    console.log("Data inserted successfully");
}

All set! You can now see your Supabase database. It has been updated.


Feel free to reach out if you have any questions or need further assistance!