Next.js Cron OG is a Next.js boilerplate that automatically fetches the top stories from Hacker News every minute using Vercel Cron Jobs, stores them in Upstash Redis, and serves dynamically generated Open Graph images via Vercel OG.
What is Next.js Cron OG?
Next.js Cron OG is a starter template that combines three Vercel services: Cron Jobs for scheduled tasks, Upstash (a Redis client) for data storage, and Vercel OG for on-the-fly Open Graph image generation. The template runs on Next.js and is authored by gt-codes in the public repository og-cron. It accepts no user input at runtime; instead it pulls the current top stories from Hacker News and produces an OG image that reflects that data, which can be attached to social sharing links.
Key Features
- Automatic Hacker News fetching — The template polls the Hacker News API every minute to retrieve the latest top stories, so the data is never more than 60 seconds stale.
- Upstash Redis storage — Fetched stories are persisted in Upstash, a serverless Redis REST client, which keeps the data available for retrieval and image generation.
- Vercel OG image generation — Using Vercel's edge-functions OG image generator, the template creates an Open Graph image on demand from the stored stories.
- Vercel Cron Jobs scheduling — The one-minute refresh cycle is driven by Vercel Cron Jobs, with no separate server or background worker needed.
- One-click Vercel deployment — The repository ships with a "Deploy with Vercel" button that sets up the Upstash integration and required environment variables automatically.
- Demo instance — A live demo is hosted at cron.vercel.zone, so you can see the output before writing your own version.
- Next.js development workflow — Standard Next.js commands (npm install, npm run dev) are enough to run the project locally.
Who is it for?
- Next.js developers who want a reference implementation for combining serverless cron jobs with edge image generation.
- Developers building content or news dashboards that need frequently refreshed social share images with minimal infrastructure.
- Vercel users looking to understand how to wire Upstash Redis into a cron-driven pipeline without managing a traditional database.
What can you do with it?
- Generate real-time OG images for hacker-news-like feeds: fetch top stories every minute and serve a shareable card that shows the current top item.
- Learn Vercel Cron + Upstash Integration: study how the environment variables (
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN) are used to connect to Upstash.
- Rapidly prototype scheduled content workflows: replace the Hacker News source with your own API or feed and reuse the cron and OG pipeline.
How does the template work?
- Clone the repository with
git clone https://github.com/gt-codes/og-cron.git.
- Copy
.env.example to .env.local and fill in your Upstash REST URL and token.
- Run
npm install and npm run dev to start locally, or deploy to Vercel with the provided button.
FAQ
Does the template require a database?
The template uses Upstash, which is a serverless Redis service that provides a REST API. You need an Upstash account and instance to store the Hacker News data; the URL and token go into your environment variables.
How often is the data updated?
A Vercel Cron Job triggers the fetch every minute. After each run, the top stories list in Upstash is refreshed, so the OG image always reflects the latest Hacker News top item.
Can I use this template outside of Vercel?
It is designed to run on Vercel, since both Cron Jobs and Vercel OG are Vercel services. Running it elsewhere would require replacing those components.
