Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Sync redirect entries from Contentful into Vercel bulk redirects using vercel.ts.
This Vercel example template, built with Next.js and Tailwind CSS, demonstrates how to sync redirect entries from Contentful into Vercel's bulk redirects at build time using the vercel.ts configuration file.
This is a reference implementation from Vercel's examples repository that pulls redirect entries from Contentful during the build step, transforms them into Vercel bulk redirect objects, and writes them to a generated-redirects.json file. It runs on the Vercel platform with Next.js and uses Tailwind CSS for the demo UI. The example is maintained by Vercel as part of their public examples collection.
vercel.ts configuration — Exports a config that points bulkRedirectsPath to the generated JSON, so Vercel publishes redirects without touching Next.js routing, middleware, or edge functions./catalog/fall-2025 or /products/daybreak-pack.CONTENTFUL_SPACE_ID and CONTENTFUL_ACCESS_TOKEN (a Contentful Delivery API token) to fetch live entries.generated-redirects.json so the app runs out of the box without credentials; when env vars exist, vercel.ts rewrites the file with real Contentful entries.bulkRedirectsPath mechanism.This example is for Next.js developers deploying on Vercel who want to manage redirects through a headless CMS instead of code changes. It's specifically useful for marketing and SEO teams that need to rotate seasonal or promotional URLs without shipping code, and for any team already using Contentful that wants an automated redirect pipeline.
The build process runs vercel.ts, which fetches redirect entries from Contentful, transforms them into Vercel bulk redirect objects, and writes them to generated-redirects.json. The config exported from vercel.ts sets bulkRedirectsPath to that file, and Vercel publishes the redirects directly to its CDN. The demo UI then displays an e-commerce catalog whose collection links resolve through those redirects.
No. The vercel.ts config handles redirects through bulkRedirectsPath, so Next.js routing, middleware, and edge functions remain untouched.
Yes. The example states you can extend it to any CMS by swapping the fetch logic while keeping the same bulkRedirectsPath mechanism.
You need CONTENTFUL_SPACE_ID for your Contentful space and CONTENTFUL_ACCESS_TOKEN — a Content Delivery API (CDA) token. Without these, the included generated-redirects.json fallback file is used for local runs.
You can use the one-click Vercel deploy button or clone the repository and run pnpm dev. The deploy button asks for the two environment variables and sets up the project automatically.
