Generating TypeScript types for remote database

I want to generate types for the cloud database tables I have hosted with Supabase. In the docs, I saw this script:
supabase start
supabase gen types typescript --local > lib/database.types.ts
supabase start
supabase gen types typescript --local > lib/database.types.ts
The question is: How do I get this to use the types for tables in my remote database? When I ran the commands as seen above, it generated types for a new local database. I haven't found a way to specificy which db I want to generate the types for in the Supabase docs.
2 Replies
Olyno
Olyno3y ago
Hi :vmathi: By default it checks your local database (--local). Check out the CLI command: https://supabase.com/docs/reference/cli/usage#supabase-gen-types-typescript
supabase gen types typescript --db-url <your_database_connection_string> > lib/database.types.ts
supabase gen types typescript --db-url <your_database_connection_string> > lib/database.types.ts
@janosch.hrm
Usage | Supabase
Supabase CLI provides you with tools to develop your application locally, and deploy your application to the Supabase platform.
janosch.hrm
janosch.hrmOP3y ago
Oh that makes a lot of sense, don't know why I didn't find that myself 🤦🏻‍♂️ Thank you so much!

Did you find this page helpful?