DaaS / Products / AI-Powered Notion App on Vercel

AI-Powered Notion App on Vercel

A developer authenticates with the Notion API, builds an AI-powered integration (e.g., semantic search or content generation over Notion pages), and deploys the resulting web application on Vercel with Notion connected as a CMS-like data source.

Products involved

Scenario

Use this workflow when building a public-facing web application that treats Notion as a headless CMS while layering AI capabilities like semantic search or automated content generation. It’s ideal for developers who need secure, user-scoped Notion data access and want Vercel’s serverless infrastructure to handle AI inference, routing, and frontend delivery.

Integration steps

  1. Create Notion Integration: In the Notion Developer Portal, register an Internal Integration. Copy the NOTION_API_KEY and note your target NOTION_DATABASE_ID.
  2. Grant Access: In the Notion UI, open your database, click •••Add connections, and select your integration to authorize API reads.
  3. Scaffold AI Route: In your Next.js/Vercel project, create pages/api/search.ts. Use @notionhq/client to fetch blocks:
  4. ``ts const res = await fetch(https://api.notion.com/v1/databases/${process.env.NOTION_DATABASE_ID}/query, { method: 'POST', headers: { Authorization: Bearer ${process.env.NOTION_API_KEY}, 'Notion-Version': '2022-06-28' }, body: JSON.stringify({ filter: { property: 'Status', status: { equals: 'Published' } } }) }); ``

  5. Embed & Query AI: Pipe retrieved text into an embedding model (e.g., text-embedding-3-small). Store vectors in Vercel Postgres or an in-memory cache, then run cosine similarity against user queries.
  6. Inject Secrets: Run vercel env add NOTION_API_KEY and vercel env add OPENAI_API_KEY in your terminal. Scope them to production and preview.
  7. Configure Vercel Integration: Add a vercel.json to automate CMS linking:
  8. ``json { "env": { "NOTION_API_KEY": "@notion", "AI_MODEL": "openai" } } ``

  9. Deploy: Commit changes, then run vercel --prod. Vercel builds the app, injects secrets, and routes traffic through serverless functions.

Architecture

Notion serves as the authoritative data layer, exposing structured content via REST. Vercel Serverless Functions fetch this data, transform it into vector embeddings, and route queries to an external AI provider. The frontend renders AI-augmented results, while Vercel manages environment injection, edge caching, and OAuth callback routing.

Prerequisites

Common pitfalls

Typical questions