hi-supabase
v1.0.4
Published
A package to keep Supabase projects alive by periodically querying the database.
Maintainers
Readme
hi-supabase 👋
One command to keep your Supabase free-tier project alive.
If you are using the Supabase free tier, your project will "pause" after a few days of inactivity. This package sets up a simple, automated "keep-alive" mechanism in your Next.js application to prevent this.
🚀 Quick Start
Run this single command in your Next.js project root:
npx hi-supabaseThat's it!
✨ What it does
This command is a generator. It scaffolds the following files into your project:
app/api/keep-alive/route.ts: An API route that queries your database.app/api/keep-alive/keepAliveUtils.ts: Utility logic for the query.config/keep-alive-config.ts: Configuration for the keep-alive behavior.lib/supabase/server.ts: A Supabase client creator (if you don't already have one).vercel.json: Automatically configures a Cron Job on Vercel to hit your API route once a day.keep-alive.sql: A SQL script to create the necessary table.
It also checks if you have @supabase/supabase-js installed and installs it if missing.
🛠️ Final Setup Steps
After running the command, you need to do two small things:
Run the SQL:
- Go to your Supabase Dashboard.
- Open the SQL Editor.
- Copy the content of the generated
keep-alive.sqlfile and run it. This creates the table used for the keep-alive check.
Deploy:
- Deploy your project to Vercel (or your preferred host).
- The
vercel.jsonfile will automatically set up the Cron Job.
🗑️ Uninstall
If you ever want to remove the files generated by hi-supabase, simply run:
npx hi-supabase uninstallThis will delete the generated API routes and config, but will safely preserve your lib/supabase/server.ts file.
📄 License
ISC
