Build a typed, headless blog in Next.js.
blogjs provides a lightweight TypeScript npm package to fetch published blog content into their own frontend. Use it to build post lists, slug-based pages, search, pagination, and rich content rendering and all while maintaining full control over your UI.
Add the SDK
Install blogjs-space in any Node 18+ JavaScript or TypeScript app.
Fetch content
Create a BlogClient and render posts in a Next.js App Router page.
Use the API
Work with typed list, detail, pagination, and content block contracts.
Ship pages
Copy practical listing and detail page patterns for production UI.
From empty app to rendered posts
The quickest integration is to create one reusable client, fetch blog lists on the server, and resolve individual posts by slug. You can keep all presentation, routing, and caching choices inside your app.
Add blogjs-space to your frontend project.
Pass your blogjs API key once at the module level.
Use getBlogs() for indexes and getBlogBySlug() for detail pages.
// step 1
npm install blogjs-space
----------------------------------------
import { BlogClient } from "blogjs-space";
// step 2
const client = new BlogClient({
apiKey: process.env.BLOGJS_API_KEY!,
});
// step 3
const posts = await client.getBlogs({
page: 1,
limit: 10,
});What the SDK handles
Paginated lists
Use getBlogs() with page, limit, and query options. Every response includes total, totalPages, and hasMore.
Search built in
Search across title, description, and slug fields without wiring your own query language.
Structured content
Detail pages can render paragraphs, headings, lists, quotes, images, and code blocks from typed content data.
Server-side friendly
The SDK uses native fetch, so it works naturally in server components, route handlers, and backend jobs.