Webflow CMS Integration for Website
Webflow — a visual website editor with a built-in CMS. Unlike Tilda, it provides a REST API for working with content collections: creating, reading, updating records programmatically. This opens several scenarios: syncing data from external systems, using Webflow CMS headlessly as a backend, or a custom frontend on top of Webflow data.
Webflow Data API v2
Since 2023, Webflow has moved to API v2. Authentication via OAuth2 (for apps) or Site API Token (for integrations):
// lib/webflow.ts
const WEBFLOW_API_TOKEN = process.env.WEBFLOW_API_TOKEN!
const SITE_ID = process.env.WEBFLOW_SITE_ID!
const BASE_URL = 'https://api.webflow.com/v2'
async function webflowFetch<T>(
path: string,
options: RequestInit = {}
): Promise<T> {
const res = await fetch(`${BASE_URL}${path}`, {
...options,
headers: {
Authorization: `Bearer ${WEBFLOW_API_TOKEN}`,
'Content-Type': 'application/json',
...options.headers,
},
next: { tags: ['webflow'] },
})
if (!res.ok) {
const err = await res.json()
throw new Error(`Webflow API error: ${err.message}`)
}
return res.json()
}
// Get list of site collections
export async function getCollections() {
return webflowFetch<{ collections: WebflowCollection[] }>(
`/sites/${SITE_ID}/collections`
)
}
// Collection items with pagination
export async function getCollectionItems(
collectionId: string,
params: { limit?: number; offset?: number; live?: boolean } = {}
) {
const query = new URLSearchParams({
limit: String(params.limit ?? 100),
offset: String(params.offset ?? 0),
...(params.live ? { live: 'true' } : {}),
})
return webflowFetch<{ items: WebflowItem[]; pagination: WebflowPagination }>(
`/collections/${collectionId}/items?${query}`
)
}
Webflow CMS Data Types
Webflow stores fields in fieldData. Fields are created in the designer, each assigned a slug:
interface BlogPost {
id: string
cmsLocaleId: string
lastPublished: string
lastUpdated: string
createdOn: string
isArchived: boolean
isDraft: boolean
fieldData: {
name: string // required Name field
slug: string // required Slug field
'post-body': string // Rich Text → HTML
'post-summary': string
'main-image': { url: string; alt: string }
'author': string // reference → id of another element
'publish-date': string
'tags': string[] // multi-reference
}
}
Next.js Integration
// app/blog/[slug]/page.tsx
import { getCollectionItems } from '@/lib/webflow'
const BLOG_COLLECTION_ID = process.env.WEBFLOW_BLOG_COLLECTION_ID!
export async function generateStaticParams() {
const { items } = await getCollectionItems(BLOG_COLLECTION_ID)
return items
.filter(item => !item.isDraft && !item.isArchived)
.map(item => ({ slug: item.fieldData.slug }))
}
export default async function PostPage({ params }: { params: { slug: string } }) {
const { items } = await getCollectionItems(BLOG_COLLECTION_ID)
const post = items.find(i => i.fieldData.slug === params.slug)
if (!post) notFound()
return (
<article>
<h1>{post.fieldData.name}</h1>
<div
className="prose"
dangerouslySetInnerHTML={{ __html: post.fieldData['post-body'] }}
/>
</article>
)
}
export const revalidate = 3600
For large collections — paginated loading:
export async function getAllItems(collectionId: string) {
const allItems = []
let offset = 0
const limit = 100
while (true) {
const { items, pagination } = await getCollectionItems(collectionId, { offset, limit })
allItems.push(...items)
if (offset + limit >= pagination.total) break
offset += limit
}
return allItems
}
Writing Data to Webflow CMS
A typical case — a form on the site saves a lead directly to a Webflow CMS collection:
export async function createCollectionItem(
collectionId: string,
fieldData: Record<string, unknown>,
options: { live?: boolean } = {}
) {
return webflowFetch(`/collections/${collectionId}/items`, {
method: 'POST',
body: JSON.stringify({
isArchived: false,
isDraft: !options.live,
fieldData,
}),
})
}
// Usage
await createCollectionItem(LEADS_COLLECTION_ID, {
name: formData.name,
email: formData.email,
message: formData.message,
source: 'contact-form',
}, { live: false }) // draft, manager will see in CMS
Webhook from Webflow
// app/api/webflow-webhook/route.ts
import { revalidateTag } from 'next/cache'
import crypto from 'crypto'
export async function POST(request: Request) {
const signature = request.headers.get('x-webflow-signature')
const body = await request.text()
// Verify signature
const expected = crypto
.createHmac('sha256', process.env.WEBFLOW_WEBHOOK_SECRET!)
.update(body)
.digest('hex')
if (signature !== expected) {
return new Response('Unauthorized', { status: 401 })
}
const payload = JSON.parse(body)
// triggerType: collection_item_created, collection_item_changed, etc.
if (payload.triggerType.startsWith('collection_item')) {
revalidateTag('webflow')
}
return new Response('OK')
}
Webhooks are set up in Webflow: Site Settings → Integrations → Webhooks.
Syncing from External System
A common case — product catalog in ERP, displayed on site via Webflow CMS:
// scripts/sync-products.ts
import { createCollectionItem, updateCollectionItem, getCollectionItems } from '@/lib/webflow'
async function syncProducts(erpProducts: ERPProduct[]) {
const { items: existing } = await getCollectionItems(PRODUCTS_COLLECTION_ID)
const existingMap = new Map(existing.map(i => [i.fieldData['sku'], i.id]))
for (const product of erpProducts) {
const fieldData = {
name: product.name,
slug: product.sku.toLowerCase(),
'product-sku': product.sku,
'price': product.price,
'in-stock': product.stock > 0,
'description': product.description,
}
if (existingMap.has(product.sku)) {
await updateCollectionItem(PRODUCTS_COLLECTION_ID, existingMap.get(product.sku)!, fieldData)
} else {
await createCollectionItem(PRODUCTS_COLLECTION_ID, fieldData, { live: true })
}
// API rate limit: 60 req/min
await new Promise(r => setTimeout(r, 1100))
}
}
API Limitations
- Rate limit: 60 requests per minute per token
- CMS collections: limit depends on plan (from 2000 to 20,000 items)
- Rich Text field returns HTML, not structured AST
- No transactions — bulk operations need to be built with partial failures in mind
Timeline
Reading data from Webflow into Next.js with ISR: 2–3 days. Two-way sync with external system: 5–7 days.







