Skip to content

Commit 415e97f

Browse files
[cdn] Create a new template for creating a docs rewrite to mintlify (#1362)
### Description This is a template for using a rewrites in vercel.ts to a docs site. This is meant to display the capabilities of the new vercel.ts project., a typsecript based configuration file. Please view the readme for more info. ### Demo URL https://docsrewrite.vercel.app/ ### Type of Change - [x] New Example - [ ] Example updates (Bug fixes, new features, etc.) - [ ] Other (changes to the codebase, but not to examples) ### New Example Checklist - [ ] 🛫 `npm run new-example` was used to create the example - [ ] 📚 The template wasn't used but I carefuly read the [Adding a new example](https://github.com/vercel/examples#adding-a-new-example) steps and implemented them in the example - [ ] 📱 Is it responsive? Are mobile and tablets considered?
1 parent ab787cd commit 415e97f

File tree

14 files changed

+1495
-0
lines changed

14 files changed

+1495
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"root": true,
3+
"extends": "next/core-web-vitals"
4+
}
5+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# Testing
9+
/coverage
10+
11+
# Next.js
12+
/.next/
13+
/out/
14+
next-env.d.ts
15+
16+
# Production
17+
build
18+
dist
19+
20+
# Misc
21+
.DS_Store
22+
*.pem
23+
24+
# Debug
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
28+
29+
# Local ENV files
30+
.env.local
31+
.env.development.local
32+
.env.test.local
33+
.env.production.local
34+
35+
# Vercel
36+
.vercel
37+
38+
# Turborepo
39+
.turbo
40+
41+
# typescript
42+
*.tsbuildinfo
43+
.env*.local
44+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
name: Mintlify docs rewrite (vercel.ts)
3+
slug: mintlify-docs-rewrite
4+
description: Serve Mintlify-hosted docs from your main domain using vercel.ts rewrites. Build a product site with seamlessly integrated documentation.
5+
framework: Next.js
6+
useCase: Rewrites
7+
css: Tailwind
8+
deployUrl: https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/cdn/mintlify-docs-rewrite&project-name=mintlify-docs-rewrite&repository-name=mintlify-docs-rewrite&env=MINTLIFY_DOCS_URL
9+
demoUrl: https://docsrewrite.vercel.app
10+
---
11+
12+
# Mintlify docs rewrite (vercel.ts) example
13+
14+
This template demonstrates how to serve Mintlify-hosted documentation from your main domain using Vercel's `vercel.ts` configuration. Instead of linking to `docs.yourdomain.com` or an external URL, your docs are seamlessly integrated at `/docs` on your product site.
15+
16+
The demo shows a fictional product site ("Flux") with docs hosted on Mintlify but served from the main domain for a unified user experience.
17+
18+
## Demo
19+
20+
https://docsrewrite.vercel.app
21+
22+
Visit the docs at `/docs` to see the Mintlify-hosted site served through the main domain.
23+
24+
## How to Use
25+
26+
You can choose from one of the following two methods to use this repository:
27+
28+
### One-Click Deploy
29+
30+
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples):
31+
32+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/cdn/mintlify-docs-rewrite&project-name=mintlify-docs-rewrite&repository-name=mintlify-docs-rewrite&env=MINTLIFY_DOCS_URL)
33+
34+
### Clone and Deploy
35+
36+
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
37+
38+
```bash
39+
pnpm create next-app --example https://github.com/vercel/examples/tree/main/cdn/mintlify-docs-rewrite
40+
```
41+
42+
Next, run Next.js in development mode:
43+
44+
```bash
45+
pnpm dev
46+
```
47+
48+
## Environment variables
49+
50+
- `MINTLIFY_DOCS_URL` – Your Mintlify custom domain URL (e.g., `https://your-subdomain.mintlify.dev`)
51+
52+
Set this in your Vercel project settings or in a `.env.local` file.
53+
54+
## How it works
55+
56+
1. You configure a custom domain in Mintlify (e.g., `your-subdomain.mintlify.dev`)
57+
2. `vercel.ts` exports a config with rewrite rules that map `/docs` and `/docs/:match*` to your Mintlify URL
58+
3. Vercel applies these rewrites at the edge, transparently proxying requests to Mintlify while preserving the original URL in the browser
59+
4. Users visit `yourdomain.com/docs` and see your Mintlify documentation as if it's part of your main site
60+
61+
## Key benefits
62+
63+
- **Better SEO**: Docs are on your main domain, not a separate subdomain
64+
- **No CORS issues**: Content is served from your domain
65+
- **Seamless branding**: Consistent experience across product and docs
66+
- **Simple setup**: Just add environment variable and deploy
67+
- **Mintlify handles infrastructure**: Focus on content while Mintlify manages hosting, CDN, and updates
68+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import Link from 'next/link'
2+
3+
export default function AboutPage() {
4+
return (
5+
<main className="min-h-screen py-16 px-4">
6+
<div className="max-w-3xl mx-auto">
7+
<Link
8+
href="/"
9+
className="inline-flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 hover:text-black dark:hover:text-white mb-8"
10+
>
11+
← Back to home
12+
</Link>
13+
14+
<h1 className="text-4xl font-bold text-black dark:text-white mb-6">
15+
About Flux
16+
</h1>
17+
18+
<div className="prose prose-gray dark:prose-invert max-w-none">
19+
<p className="text-lg text-gray-600 dark:text-gray-400 mb-8">
20+
Flux is a real-time event platform designed to make it easy to build event-driven applications. Whether you&apos;re sending transactional events, processing webhooks, or building real-time notifications, Flux handles the infrastructure so you can focus on your product.
21+
</p>
22+
23+
<div className="space-y-8">
24+
<section className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
25+
<h2 className="text-xl font-semibold text-black dark:text-white mb-3">
26+
Built for scale
27+
</h2>
28+
<p className="text-gray-600 dark:text-gray-400">
29+
From thousands to millions of events per second, Flux automatically scales to handle your traffic. Events are persisted to durable storage and retried with exponential backoff to guarantee delivery.
30+
</p>
31+
</section>
32+
33+
<section className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
34+
<h2 className="text-xl font-semibold text-black dark:text-white mb-3">
35+
Developer experience first
36+
</h2>
37+
<p className="text-gray-600 dark:text-gray-400 mb-4">
38+
Drop-in SDKs for all major languages make integration seamless. Comprehensive API documentation and example code get you up and running in minutes.
39+
</p>
40+
</section>
41+
42+
<section className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
43+
<h2 className="text-xl font-semibold text-black dark:text-white mb-3">
44+
Complete observability
45+
</h2>
46+
<p className="text-gray-600 dark:text-gray-400">
47+
Track every event with detailed logs, traces, and delivery analytics. Debug production issues quickly with comprehensive error context and retry history.
48+
</p>
49+
</section>
50+
51+
<section className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
52+
<h2 className="text-xl font-semibold text-black dark:text-white mb-3">
53+
Secure by default
54+
</h2>
55+
<p className="text-gray-600 dark:text-gray-400">
56+
All events are encrypted in transit and at rest. Webhook signatures are automatically verified to prevent spoofing. Fine-grained access controls let you manage API keys and permissions with ease.
57+
</p>
58+
</section>
59+
</div>
60+
</div>
61+
</div>
62+
</main>
63+
)
64+
}
65+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@import "tailwindcss";
2+
3+
:root {
4+
--background: #ffffff;
5+
--foreground: #171717;
6+
}
7+
8+
@theme inline {
9+
--color-background: var(--background);
10+
--color-foreground: var(--foreground);
11+
--font-sans: var(--font-geist-sans);
12+
--font-mono: var(--font-geist-mono);
13+
}
14+
15+
@media (prefers-color-scheme: dark) {
16+
:root {
17+
--background: #0a0a0a;
18+
--foreground: #ededed;
19+
}
20+
}
21+
22+
body {
23+
background: var(--background);
24+
color: var(--foreground);
25+
font-family: Arial, Helvetica, sans-serif;
26+
}
27+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { Metadata } from 'next'
2+
import type { ReactNode } from 'react'
3+
import { GeistSans } from 'geist/font/sans'
4+
import { GeistMono } from 'geist/font/mono'
5+
import Navbar from '../components/Navbar'
6+
import './globals.css'
7+
8+
export const metadata: Metadata = {
9+
title: 'Flux - Real-time event infrastructure',
10+
description: 'Send, receive, and react to events across your entire stack with a simple API.',
11+
}
12+
13+
export default function RootLayout({ children }: { children: ReactNode }) {
14+
return (
15+
<html lang="en" className={`${GeistSans.variable} ${GeistMono.variable}`}>
16+
<body className="antialiased bg-white dark:bg-black text-gray-900 dark:text-gray-100">
17+
<Navbar />
18+
{children}
19+
</body>
20+
</html>
21+
)
22+
}
23+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Link from 'next/link'
2+
3+
export default function NotFound() {
4+
return (
5+
<main className="min-h-screen flex items-center justify-center px-4">
6+
<div className="text-center">
7+
<h1 className="text-6xl font-bold text-black dark:text-white mb-4">404</h1>
8+
<p className="text-xl text-gray-600 dark:text-gray-400 mb-8">
9+
Page not found
10+
</p>
11+
<Link
12+
href="/"
13+
className="inline-flex items-center justify-center bg-black dark:bg-white text-white dark:text-black px-6 py-3 rounded-lg font-medium hover:bg-gray-800 dark:hover:bg-gray-200 transition-colors"
14+
>
15+
Go home
16+
</Link>
17+
</div>
18+
</main>
19+
)
20+
}
21+
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import Link from 'next/link'
2+
3+
export default function Home() {
4+
return (
5+
<main className="min-h-screen">
6+
<section className="py-24 px-4 border-b border-gray-200 dark:border-gray-800">
7+
<div className="max-w-4xl mx-auto text-center">
8+
<h1 className="text-5xl md:text-6xl font-bold tracking-tight text-black dark:text-white mb-6">
9+
Flux
10+
</h1>
11+
<p className="text-xl text-gray-600 dark:text-gray-400 mb-10 max-w-2xl mx-auto">
12+
Real-time event infrastructure for modern applications. Send, receive, and react to events across your entire stack with a simple API.
13+
</p>
14+
<div className="flex flex-col sm:flex-row gap-4 justify-center">
15+
<Link
16+
href="/docs"
17+
className="inline-flex items-center justify-center bg-black dark:bg-white text-white dark:text-black px-8 py-3 rounded-lg font-medium hover:bg-gray-800 dark:hover:bg-gray-200 transition-colors"
18+
>
19+
Read Documentation →
20+
</Link>
21+
<a
22+
href="https://github.com"
23+
className="inline-flex items-center justify-center border border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 px-8 py-3 rounded-lg font-medium hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors"
24+
>
25+
View on GitHub
26+
</a>
27+
</div>
28+
</div>
29+
</section>
30+
31+
<section className="py-20 px-4">
32+
<div className="max-w-6xl mx-auto">
33+
<div className="text-center mb-16">
34+
<h2 className="text-3xl font-bold text-black dark:text-white mb-4">
35+
Why Flux
36+
</h2>
37+
<p className="text-gray-600 dark:text-gray-400 max-w-xl mx-auto">
38+
Purpose-built for event-driven applications at any scale.
39+
</p>
40+
</div>
41+
42+
<div className="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
43+
<div className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
44+
<h3 className="text-lg font-semibold text-black dark:text-white mb-2">Simple Integration</h3>
45+
<p className="text-gray-600 dark:text-gray-400 text-sm">
46+
Drop-in SDKs for Node.js, Python, Go, and more. Start sending events in minutes.
47+
</p>
48+
</div>
49+
50+
<div className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
51+
<h3 className="text-lg font-semibold text-black dark:text-white mb-2">Guaranteed Delivery</h3>
52+
<p className="text-gray-600 dark:text-gray-400 text-sm">
53+
Events are persisted and retried automatically. Never lose critical data.
54+
</p>
55+
</div>
56+
57+
<div className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
58+
<h3 className="text-lg font-semibold text-black dark:text-white mb-2">Real-time Webhooks</h3>
59+
<p className="text-gray-600 dark:text-gray-400 text-sm">
60+
Receive events instantly via webhooks with automatic signature verification.
61+
</p>
62+
</div>
63+
64+
<div className="border border-gray-200 dark:border-gray-800 rounded-xl p-6">
65+
<h3 className="text-lg font-semibold text-black dark:text-white mb-2">Full Observability</h3>
66+
<p className="text-gray-600 dark:text-gray-400 text-sm">
67+
Debug issues fast with event logs, traces, and delivery analytics.
68+
</p>
69+
</div>
70+
</div>
71+
</div>
72+
</section>
73+
74+
<section className="py-16 px-4 border-t border-gray-200 dark:border-gray-800">
75+
<div className="max-w-4xl mx-auto">
76+
<h3 className="text-2xl font-bold text-black dark:text-white mb-6 text-center">
77+
Quick example
78+
</h3>
79+
<p className="text-gray-600 dark:text-gray-400 mb-4 text-center">
80+
Send your first event in minutes
81+
</p>
82+
<div className="bg-gray-950 rounded-xl p-6 overflow-x-auto">
83+
<pre className="text-sm text-gray-300 font-mono">
84+
{`import Flux from '@flux/node';
85+
86+
const flux = new Flux('sk_live_...');
87+
88+
await flux.events.send({
89+
type: 'user.signup',
90+
data: {
91+
userId: 'usr_123',
92+
email: 'jane@example.com',
93+
plan: 'pro'
94+
}
95+
});`}
96+
</pre>
97+
</div>
98+
</div>
99+
</section>
100+
</main>
101+
)
102+
}
103+

0 commit comments

Comments
 (0)