A CLI tool to add exports for your supabase tables
npm install better-supabase-types  
ts
import { Database } from './src/schema.ts';
type Todo = Database['public']['Tables']['Todo']['Row'];
const todos: Todo[] = [];
`
$3
`ts
import { Todo } from './src/newSchema.ts';
const todos: Todo[] = [];
`
Usage 🔨
1. First have your supabase typescript file generated Supabase Docs
`bash
npx supabase gen types typescript --linked --schema public > ./src/schema.ts
`
2. Run the better-supabase-types command (you can also use a config file):
`bash
npx better-supabase-types -i ./src/schema.ts -o ./src/newSchema.ts
`
Commands 💻
`
Options:
--version Show version number [boolean]
--help Show help [boolean]
-i, --input Path to the input file [string] [required]
-o, --output Path to the output file [string]
-p, --prettier Path to the prettier config file
[string] [default: ".prettierrc"]
-f, --force Force the overwrite of the input file [boolean]
-s, --singular Convert table names to singular form instead of plural form
[boolean] [default: false]
--enumAsType Have converted enums defined as types and not enums
[boolean] [default: false]
--enumPascalCase Enums format to pascal case [boolean] [default: false]
`
$3
You can also use a config named .betterrc.json:
`json
{
"input": "./src/schema.ts",
"force": true,
"singular": true
}
`
#### package.json 📦
You can also put your config file in your package.json file:
`json
{
"name": "better-supabase-types",
"...": "...",
"betterConfig": {
"input": "./schema.ts",
"output": "./newSchema.ts"
}
}
``