How to Install Bubblegum: Developer Guide (Vercel Edition)
Introduction
Modern AI tools like ChatGPT, Perplexity, and Claude are becoming key discovery engines — crawling, interpreting, and recommending brand content. To ensure these tools interpret your site accurately, Bubblegum offers a lightweight middleware solution.
This comprehensive guide covers the complete setup and deployment process for Bubblegum Middleware for Vercel-hosted sites.
What is Middleware?
AI agents are now an important segment of web traffic, discovering, indexing, and interacting with your digital content. This middleware acts as an intelligent router – seamlessly directing recognized AI bot traffic to AI-optimized, relevant pages while serving regular visitors as normal.
How It Works
Interception
The Middleware sits between your domain and all incoming traffic
Bot Detection
Each request's user-agent (and optionally headers) are checked against a curated list of bot patterns, including major LLMs, scrapers, and headless browsers
Dynamic Routing
AI bot requests: Redirected to an AI-ready version of the content (e.g.,
/aboutbecomes/about.md)Non-bot traffic: Served as usual with no disruption or latency
Setup Instructions (Vercel Projects)
Bubblegum supports two integration approaches for Vercel projects, depending on your framework and routing needs:
1. Using vercel.json (Framework Agnostic)
vercel.json (Framework Agnostic)Works for any site hosted on Vercel, including static sites, non-Next.js frameworks, and custom setups.
Pros:
Framework agnostic: You don’t need Next.js or any specific tech stack.
Simple setup: One file, predictable rewrite rules.
Cons:
No fallback logic: If a page isn’t available in
.mdAI-optimized form, the bot will not get a fallback version.Requires coverage: You'll need to ensure all intended pages are provided as
.mdversions.
How to Setup
Add a
vercel.jsonfile at the root of your project, or update your existing one:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"rewrites": [
{
"source": "/:path*",
"has": [
{
"type": "header",
"key": "user-agent",
"value": "(?i).*(GPTBot|ChatGPT-User|Anthropic-AI|ClaudeBot|Claude-Web|PerplexityBot|OAI-SearchBot|openai\\.com/bot).*"
}
],
"missing": [
{
"type": "query",
"key": "path",
"value": ".*\\.(css|js|jpg|jpeg|png|gif|svg|ico|woff|woff2|ttf|eot|pdf|zip|mp4|mp3|avi|mov|wmv|flv|webm|ogg|wav|aac|m4a|flac|doc|docx|xls|xlsx|ppt|pptx|txt|xml|json|yaml|yml|md|html|htm)$"
}
],
"destination": "https://<YOUR_BUBBLEGUM_MARKDOWN_DOMAIN>/:path*.md"
}
]
}Replace https://<YOUR_BUBBLEGUM_MARKDOWN_DOMAIN> with the custom Bubblegum domain provided to you (usually shared via onboarding or by [email protected])
Commit and Deploy:
Commit your changes and trigger a redeploy in Vercel.
The rules are picked up automatically, no additional code is required.
2. Next.js Middleware Approach (Fine-Grained Control)
Gives you flexible, programmatic control—ideal for Next.js projects.
Pros:
Supports fallback logic: If a page doesn’t exist in
.md, bots get standard site content as a fallback.Customizable: Define bot detection, logging, IP range controls, etc.
Cons:
Requires basic knowledge of Next.js middleware/configuration.
How to Setup
Add this
middleware.tsfile at the root of your Next.js project:
All the code you provided, including helper functions, bot logic, config, and AI routing, should be copied verbatim.
Add this auto-generated
ai-ip-addresses.tsat the project root:
This ensures known bot IP detection stays current.
File will be updated as new AI services are onboarded.
BUBBLEGUM_AI_URL:
The AI routing URL will be provided via onboarding, or you can request this from [email protected].
Commit and Deploy (Agnostic):
Once both files are added/updated, commit changes and redeploy as usual.
The rules are picked up automatically, no additional code is required.
How to Test
To verify that bot redirects are working as expected:
Use a tool like curl or Postman
Send a request with one of the bot user-agent headers (e.g. GPTBot)
Confirm the request is rewritten to the .md version hosted on your Bubblegum domain
Need help generating a test command? Reach out to us at [email protected]
Decision Table: Which Option Should You Use?
vercel.json
Any Vercel site
❌
Basic rewriting
Static sites, non-Next.js
Next.js middleware
Next.js only
✅
Advanced (logging, IPs, custom routing)
Next.js, hybrid, or dynamic sites
Additional Resources
Frequently Asked Questions:
Last updated
Was this helpful?

