Files
Katerina Skroumpelou 6eb40f17a7 docs: purge safeGetSession + getUser from auth example code (#47042)
Sweeps the example code that creating-a-client.mdx and other auth docs
pull via $CodeSample, so the rendered pages match the "use getClaims()"
guidance. Also adds Database type stubs and parameterizes
SupabaseClient<Database> across SvelteKit and Hono examples.

Fixes #40985 


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

* **Documentation**
* Updated OAuth server getting-started guide to use a claims-based
consent/auth gate and preserve the authorization identifier on redirect.
* Added the `auth_methods` partial across framework sections in the
server-side “creating a client” guide.

* **Refactor**
* Updated authentication examples for Hono, Next.js, and SvelteKit to
rely on JWT claims for logged-in checks and protected routes.
* Streamlined example auth state and UI rendering to use claims-derived
information.

* **Type Updates**
* Improved TypeScript typing for Supabase clients and app auth data
across examples, including generated database type stubs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
2026-06-17 17:53:27 +02:00
..

Hono Supabase Auth Example

Based on the Hono/JSX + Vite example by @MathurAditya724 \o/

This example shows how to use Supabase Auth both on the client and server side with Hono.

Supabase setup

  • Create a new Supabase project at database.new
  • Go to the SQL Editor and run the following query to create the countries table.
-- Create the table
create table countries (
  id bigint primary key generated always as identity,
  name text not null
);
-- Insert some sample data into the table
insert into countries (name)
values
  ('Canada'),
  ('United States'),
  ('Mexico');

alter table countries enable row level security;
  • In a new query, create the following access policy.
create policy "authenticated users can read countries"
on public.countries
for select to authenticated
using (true);

Setup

  • Run npm install to install the dependencies.
  • Run cp .env.example .env.
  • Set the required environment vairables in your .env file.

Commands

Run the vite dev server

npm run dev

Building

npm run build

This project is configured to use node runtime, you can change it to your desired runtime in the vite.config.js file. We are using @hono/vite-build package for building the project and @hono/vite-dev-server for running the dev server.