Getting started
Quickstart
Create a client instance and fetch your first blog list in under a minute.
- 1Instantiate the client
Create a single shared client at the module level so it is reused across requests.
Codeimport { BlogClient } from "blogjs-space"; const client = new BlogClient({ apiKey: "your-project-api-key", }); - 2Fetch blogs in a server componentCode
// app/blogs/page.tsx export default async function BlogsPage() { const result = await client.getBlogs({ page: 1, limit: 10, }); return ( <ul> {result.data.map((blog) => ( <li key={blog.slug}>{blog.title}</li> ))} </ul> ); } - 3Fetch a single blog by slugCode
// app/blogs/[slug]/page.tsx export default async function BlogPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const blog = await client.getBlogBySlug(slug); if (!blog) return <p>Not found</p>; return <h1>{blog.title}</h1>; }