Getting Started

Use Supabase with Hono

Learn how to create a Supabase project, add some sample data to your database, secure it with auth, and query the data from a Hono app.


1

Create a Supabase project

Go to database.new and create a new Supabase project.

When your project is up and running, go to the Table Editor, create a new table and insert some data.

Alternatively, you can run the following snippet in your project's SQL Editor. This will create a countries table with some sample data.

SQL_EDITOR

_13
-- Create the table
_13
create table countries (
_13
id bigint primary key generated always as identity,
_13
name text not null
_13
);
_13
-- Insert some sample data into the table
_13
insert into countries (name)
_13
values
_13
('Canada'),
_13
('United States'),
_13
('Mexico');
_13
_13
alter table countries enable row level security;

Make the data in your table publicly readable by adding an RLS policy:

SQL_EDITOR

_10
create policy "public can read countries"
_10
on public.countries
_10
for select to anon
_10
using (true);

2

Create a React app

Boostrap the Hono example app from the Supabase Samples using the CLI.

Terminal

_10
npx supabase@latest bootstrap hono

3

Install the Supabase client library

The package.json file in the project includes the necessary dependencies, including @supabase/supabase-js and @supabase/ssr to help with server-side auth.

Terminal

_10
npm install

4

Set up the required environment variables

Copy the .env.example file to .env and update the values with your Supabase project URL and anon key.

Lastly, enable anonymous sign-ins in the Auth settings.

Project URL
Anon key
Terminal

_10
cp .env.example .env

5

Start the app

Start the app, go to http://localhost:5173.

Terminal

_10
npm run dev

Next steps