On this page
Headless blog (@v-tilt/content)
Last updated
Read published posts from the Content API with delivery or preview keys, Next.js helpers, and webhook revalidation.
Use @v-tilt/content when your own Next.js (or Node) site renders a blog stored in vTilt. Authors write in Studio, MCP, or the management REST API; your site reads the published snapshot with a delivery key.
Important: Content is enabled per project. Mint a delivery (vtc_…) or preview (vtp_…) key from the management API (POST /api/v1/content/manage/keys) before calling the public routes.
#Install
npm install @v-tilt/content#Keys
| Key | Prefix | Reads | Where it may live |
|---|---|---|---|
| Delivery | vtc_ | Published posts only | Server or browser |
| Preview | vtp_ | Drafts too | Server only — the client throws if it sees one in a browser |
Management keys (vtu_) and the tracker token (vt_) do not work on the public read API.
#Core client
import { createContentClient } from '@v-tilt/content'
const content = createContentClient({
key: process.env.VTILT_CONTENT_KEY!, // vtc_… or vtp_…
// baseUrl: 'https://www.vtilt.com',
})
const { posts, next_cursor } = await content.listPosts({ limit: 10 })
const post = await content.getPost('hello-world') // null when not found| Method | Path |
|---|---|
listPosts | GET /api/v1/content/posts |
getPost | GET /api/v1/content/posts/{slug} |
listTerms / listAuthors | GET /terms, /authors |
listRedirects / findRedirect | GET /redirects |
getFeed / getSitemap | GET /feed.xml, /feed.json, /sitemap |
Failures throw ContentApiError with code, status, and optional next / details.
#Next.js helpers
import {
createNextContentClient,
createRevalidateHandler,
} from '@v-tilt/content/next'
export const content = createNextContentClient({
key: process.env.VTILT_CONTENT_KEY!,
})
// app/api/vtilt/revalidate/route.ts
export const POST = createRevalidateHandler({
secret: process.env.VTILT_CONTENT_WEBHOOK_SECRET!,
})createNextContentClient tags fetches with vtilt-content / vtilt-post-slug-… so the webhook can purge them. Preview keys bypass the cache.
#Webhooks
Register an endpoint with create_content_webhook (MCP) or POST /api/v1/content/manage/webhooks. Verify signatures with verifyWebhookSignature from @v-tilt/content (X-Vtilt-Signature: t=…,v1=…).
#Attribution
On each post page, call vt.setPageContext({ contentId, contentSlug, contentCollection: 'posts' }) so analytics events carry $content_id for per-post stats in Studio.
#Related
- OpenAPI for management routes:
GET /api/v1/content/openapi.json - Package README and example app live in the
@v-tilt/contentsource package