Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 5.27 KB

File metadata and controls

61 lines (44 loc) · 5.27 KB

🏡 Home

Start a new Supabase project Create a Next.js app with the create-next-app CLI Query Supabase data from Next.js Server Components Create an OAuth app with GitHub Authenticate users with GitHub OAuth using Supabase and Next.js Client Components Refresh session cookie for Next.js Server Components with Middleware Restrict access to authenticated users with RLS policies Dynamically render UI based on user session with SSR in Next.js Client Components Implement Protected Routes for authenticated users with Supabase Auth Generate TypeScript definitions from PostgreSQL schema with Supabase CLI Setup a Foreign Key relationship between PostgreSQL tables Automatically generate a profile for every user with PostgreSQL Function Triggers Run authenticated Server-side mutations with Next.js Server Actions Create a PostgreSQL join table in Supabase Studio Implement dynamic buttons with Next.js Client Components Declare global union types with Typescript Implement Optimistic UI with the Next.js useTransition hook Dynamically update UI with Database changes using Supabase Realtime Style a Twitter clone with Tailwind CSS Deploy Next.js App Router project to production with Vercel

Generate TypeScript definitions from PostgreSQL schema with Supabase CLI

📹 Video

Typescript reduces runtime errors and makes our code more maintainable. Supabase allows us to introspect our PostgreSQL schema and generate TypeScript definitions.

In this lesson we generate an access token to use the Supabase CLI and generate TypeScript definitions. Additionally, we write our types to a file, which can be passed to our Supabase client, giving our application full type-safety across client, server and database.

Lastly, we make our Database types globally available so we don't need to import them every time we create a Supabase client.

Code Snippets

Login to Supabase CLI

npx supabase login

Generate TS definitions file

npx supabase gen types typescript --project-id your-project-id > lib/database.types.ts

Resources


👉 Next lesson


Enjoying the course? Follow Jon Meyers on Twitter and subscribe to the YouTube channel.