supabase in typescript

To use Supabase with TypeScript, you can follow these steps:

  1. Install Supabase Client
index.ts
npm install @supabase/supabase-js
34 chars
2 lines
  1. Import Supabase Client
index.ts
import { createClient } from "@supabase/supabase-js";

// Connect to your Supabase project
const supabase = createClient(
  "https://<your-project>.supabase.co",
  "<your-public-api-key>"
);
191 chars
8 lines
  1. Use Supabase Client
index.ts
async function fetchAllUsers() {
  // Call the "users" table from Supabase
  const { data: users, error } = await supabase.from("users").select("*");

  if (error) {
    console.log(error);
  } else {
    console.log(users);
  }
}
231 chars
11 lines

These are just basic examples, but you can extend your usage of Supabase with TypeScript to suit your needs.

gistlibby LogSnag