{"id":19764135,"url":"https://github.com/travisvn/supabase-pause-prevention","last_synced_at":"2025-03-17T16:10:19.892Z","repository":{"id":237580647,"uuid":"794810506","full_name":"travisvn/supabase-pause-prevention","owner":"travisvn","description":"Prevent Supabase projects from getting paused due to inactivity","archived":false,"fork":false,"pushed_at":"2024-10-10T21:08:08.000Z","size":116,"stargazers_count":65,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T10:01:39.991Z","etag":null,"topics":["automation","collaborate","database","free","github","javascript","next","nextjs","react","reactjs","sql","startup","startups","student-vscode","supabase","template","templates","typescript","vercel"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travisvn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-02T02:09:03.000Z","updated_at":"2025-03-01T00:32:18.000Z","dependencies_parsed_at":"2024-05-09T21:31:47.301Z","dependency_job_id":"e0019c7b-b5fc-41ed-8d98-de40560612f7","html_url":"https://github.com/travisvn/supabase-pause-prevention","commit_stats":null,"previous_names":["travisvn/supabase-pause-prevention"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-pause-prevention","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-pause-prevention/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-pause-prevention/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-pause-prevention/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travisvn","download_url":"https://codeload.github.com/travisvn/supabase-pause-prevention/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066179,"owners_count":20392406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","collaborate","database","free","github","javascript","next","nextjs","react","reactjs","sql","startup","startups","student-vscode","supabase","template","templates","typescript","vercel"],"created_at":"2024-11-12T04:12:38.068Z","updated_at":"2025-03-17T16:10:19.864Z","avatar_url":"https://github.com/travisvn.png","language":"TypeScript","readme":"# Supabase Pause Prevention ⏸️\n\n![GitHub stars](https://img.shields.io/github/stars/travisvn/supabase-pause-prevention?style=social)\n![GitHub forks](https://img.shields.io/github/forks/travisvn/supabase-pause-prevention?style=social)\n![GitHub repo size](https://img.shields.io/github/repo-size/travisvn/supabase-pause-prevention)\n![GitHub language count](https://img.shields.io/github/languages/count/travisvn/supabase-pause-prevention)\n![GitHub top language](https://img.shields.io/github/languages/top/travisvn/supabase-pause-prevention)\n![GitHub last commit](https://img.shields.io/github/last-commit/travisvn/supabase-pause-prevention?color=red)\n![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Ftravisvn%2Fsupabase-pause-prevention\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026icon=\u0026icon_color=%23E7E7E7\u0026title=hits\u0026edge_flat=false)\n[![](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://img.shields.io/github/sponsors/travisvn)\n\n🛑 Stop Supabase projects from pausing due to inactivity! :raised_hands:\n\n\u003e On the free-tier plan, projects that are inactive for more than 7 days are paused.\n\n\n# Please star ⭐️ if you find this useful \n\n\n\u003e [!TIP]\n\u003e __NEW \u0026 IMPROVED VERSION__ written in Python available at [supabase-inactive-fix repo](https://github.com/travisvn/supabase-inactive-fix)\n\n\n\n## Solution / How it works\n\n- Creating a _cron job_ (scheduled task) that makes a simple database call\n  - _(This keeps your Supabase project active)_\n- Fetching `keep-alive.ts` API endpoints for the other projects, as Vercel limits free-tier users to one cron job.\n\n## Getting Started\n\n**Super simple to add to your existing Supabase project!**\n\n### Configure your main project\n\n_Only 3 files matter_\n\n- [`/app/api/keep-alive/route.ts`](app/api/keep-alive/route.ts) - API endpoint the cron job will execute\n- [`/app/api/keep-alive/helper.ts`](app/api/keep-alive/helper.ts) - Helper functions called from `route.ts`\n- [`/config/keep-alive-config.ts`](config/keep-alive-config.ts) - Configuration for your setup\n- [`/vercel.json`](vercel.json) - Directs Vercel to periodically run the `keep-alive` endpoint\n\n`utils/supabase` folder contains files provided in the Supabase docs for the [Next.js Web App demo — Supabase](https://supabase.com/docs/guides/getting-started/tutorials/with-nextjs)\n\nEverything else is boilerplate from Next.js `create-next-app`\n\n### Configuring your other Supabase projects\n\nAfter selecting your primary project _(the one that implements the code provided in this repository)_, you'll want to add an API endpoint to your other Supabase projects\n\nThe only requirement is that this endpoint is reachable and makes a call to your Supabase database\n\n\n\u003e [!NOTE]\n\u003e API endpoint must make database call   \n\u003e Ensure the server doesn't cache this\n\n\n\u003cdetails\u003e\n\n\u003csummary\u003eExample of a setup using Prisma as an ORM\u003c/summary\u003e\n\n`/pages/api/keep-alive.ts` \n\n```typescript\n// Next.js API route support: https://nextjs.org/docs/api-routes/introduction\nimport type { NextApiRequest, NextApiResponse } from 'next'\nimport { prisma } from 'src/server/db'\n\n// See next example for contents of @/utils/helper\nimport { generateRandomString } from '@/utils/helper'\n\nexport default async function handler(\n  _req: NextApiRequest,\n  res: NextApiResponse\n) {\n  try {\n    const randomString = generateRandomString()\n    const dbResponse = await prisma.keepAlive.findMany({\n      where: {\n        name: {\n          equals: randomString,\n        }\n      }\n    })\n    const successMessage = (dbResponse != null) ? `Success - found ${dbResponse.length} entries` : \"Fail\"\n    res.status(200).json(successMessage)\n  } catch (e) {\n    res.status(401).send(\"There was an error\")\n  }\n}\n```\n\n`/prisma/schema.prisma`\n\n```prisma\n// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n  provider        = \"prisma-client-js\"\n  previewFeatures = [\"postgresqlExtensions\"]\n}\n\ndatasource db {\n  provider   = \"postgresql\"\n  url        = env(\"DATABASE_URL\")\n  extensions = [uuidOssp(map: \"uuid-ossp\")]\n}\n\nmodel KeepAlive {\n  id     BigInt  @id @default(autoincrement())\n  name   String? @default(\"\")\n  random String? @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n  \u003csummary\u003eHelper function for '/pages' directory (legacy support)\u003c/summary\u003e\n\n  `/utils/helper.ts`\n\n  ```typescript\n  const defaultRandomStringLength: number = 12\n  \n  const alphabetOffset: number = 'a'.charCodeAt(0)\n  export const generateRandomString = (length: number = defaultRandomStringLength) =\u003e {\n    let newString = ''\n  \n    for (let i = 0; i \u003c length; i++) {\n      newString += String.fromCharCode(alphabetOffset + Math.floor(Math.random() * 26))\n    }\n  \n    return newString\n  }\n  ```\n\u003c/details\u003e\n\n### Sample SQL \n\nAny table and column can be called, but if you'd rather go with a generic, here's a SQL query for a `keep-alive` table \n\n```sql\nCREATE TABLE \"keep-alive\" (\n  id BIGINT generated BY DEFAULT AS IDENTITY,\n  name text NULL DEFAULT '':: text,\n  random uuid NULL DEFAULT gen_random_uuid (),\n  CONSTRAINT \"keep-alive_pkey\" PRIMARY key (id)\n);\n\nINSERT INTO\n  \"keep-alive\"(name)\nVALUES\n  ('placeholder'),\n  ('example');\n```\n\n\u003e [!IMPORTANT]\n\u003e It is now **strongly recommended** to use a `keep-alive` table like the one above.   \n\u003e This is in light of the added features for _optional_ database insertion \u0026 deletion actions\n\n___\n\n### Sample response\n\nVisiting `https://your-project-domain.vercel.app/api/keep-alive` \n\n```\nResults for retrieving\n'mzmgylpviofc' from 'keep-alive' at column 'name': []\n\nOther Endpoint Results:\nhttps://your-other-vercel-project-urls.vercel.app/api/keep-alive - Passed\nhttps://your-other-supabase-app.com/api/keep-alive - Passed\n\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eExtended response (with insertion / deletion)\u003c/summary\u003e\n  \n```\nResults for retrieving entries from 'keep-alive' - 'name column: [{\"name\":\"placeholder\"},{\"name\":\"random\"}, ... ,{\"name\":\"uujyzdnsbrgi\"}]\n\nResults for deleting\n'uujyzdnsbrgi' from 'keep-alive' at column 'name': success\n```\n\n\u003c/details\u003e\n\n___\n\nThis is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisvn%2Fsupabase-pause-prevention","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravisvn%2Fsupabase-pause-prevention","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisvn%2Fsupabase-pause-prevention/lists"}