A starter template for building Pay-As-You-Go apps with Next.js, Unkey and Supabase
Features · Clone and run locally · More Examples
- Robust API key management via the @unkey/api:
- Efficient creation and tier management
- Precise quota enforcement
- Accurate total cost calculations
- Effortless tier upgrades without additional lookups
- Usage analytics
- Scheduled background jobs utilizing Vercel Crons:
- Automated clean-up of obsolete API keys
- Streamlined creation of new API keys
- supabase-ssr. A package to configure Supabase Auth to use cookies
- Styling with Tailwind CSS
- Go to the Supabase dashboard.
- Create a new project and configure database.
- Head over to Unkey settings.root-keys.
- Click "Create New Root Key".
- Enter the key name.
- Click "Create".
- Now, go to apis and click on the "Create New API" button.
- Give it a name.
- Click "Create".
-
Clone the repository
git clone git@github.com:unrenamed/unkey-nextjs-pay-as-you-go cd unkey-nextjs-pay-as-you-go
-
Install the dependencies
pnpm install
-
Use
.env.example
to create.env.local
file and update the following:NEXT_PUBLIC_SUPABASE_URL=your-project-url NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_ROLE_KEY=your-serice-role-key UNKEY_ROOT_KEY=your-unkey-root-key UNKEY_API_ID=your-unkey-api-id CRON_SECRET=your-cron-secret
You will find more info about where to get each variable in the file.
-
You can now run the Next.js local development server:
pnpm dev
The starter kit should now be running on localhost:3000.