Display the articles RankBolt writes on your own website, with your own design.
Setup time
~10 minutes
Auth method
API key (Bearer)
Content format
Markdown
Get your API key, add it to a Next.js site, show your articles and publish a new one, in under 3 minutes.
Copy your key from Settings → Integrations and add it to .env.local at the root of your project.
RANKBOLT_API_KEY=your_api_keyThe API returns each article body as Markdown. react-markdown turns it into HTML.
npm install react-markdown remark-gfmOne file that calls the RankBolt API with your key and caches the answer for 60 seconds.
const API = "https://rankbolt.ai/api/v1";
export type Article = {
id: string;
slug: string | null;
title: string;
excerpt: string | null;
content: string; // Markdown
featured_image: string | null;
published_at: string | null;
meta_title: string | null;
meta_description: string | null;
reading_time: number | null;
author: { name: string; image: string | null } | null;
tags: { id: number; name: string; slug: string }[];
};
async function rankbolt<T>(path: string): Promise<T | null> {
const res = await fetch(`${API}${path}`, {
headers: { Authorization: `Bearer ${process.env.RANKBOLT_API_KEY}` },
next: { revalidate: 60 }, // refresh at most once a minute
});
if (res.status === 404) return null;
if (!res.ok) throw new Error(`RankBolt API error ${res.status}`);
return res.json();
}
export async function getArticles(limit = 9, offset = 0) {
const json = await rankbolt<{
data: Article[];
meta: { total: number; limit: number; offset: number };
}>(`/articles?limit=${limit}&offset=${offset}`);
return json ?? { data: [], meta: { total: 0, limit, offset } };
}
export async function getArticle(slug: string) {
const json = await rankbolt<{ data: Article }>(
`/articles/${encodeURIComponent(slug)}`,
);
return json?.data ?? null;
}A server component that lists your published articles, newest first.
import Link from "next/link";
import { getArticles } from "@/lib/rankbolt";
export default async function BlogPage() {
const { data: articles } = await getArticles(9);
return (
<main className="mx-auto max-w-5xl px-6 py-16">
<h1 className="text-4xl font-semibold">Blog</h1>
<div className="mt-10 grid gap-8 md:grid-cols-3">
{articles.map((article) => (
<Link key={article.id} href={`/blog/${article.slug}`}>
{article.featured_image && (
<img
src={article.featured_image}
alt={article.title}
className="rounded-xl"
/>
)}
<h2 className="mt-4 text-xl font-medium">{article.title}</h2>
<p className="mt-2 text-sm text-gray-600">{article.excerpt}</p>
</Link>
))}
</div>
</main>
);
}Renders one article and sets its SEO title, description and share image.
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { getArticle } from "@/lib/rankbolt";
type Props = { params: Promise<{ slug: string }> };
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
const article = await getArticle(slug);
if (!article) return {};
return {
title: article.meta_title ?? article.title,
description: article.meta_description ?? article.excerpt ?? undefined,
openGraph: {
images: article.featured_image ? [article.featured_image] : [],
},
};
}
export default async function ArticlePage({ params }: Props) {
const { slug } = await params;
const article = await getArticle(slug);
if (!article) notFound();
return (
<article className="prose mx-auto max-w-3xl px-6 py-16">
<h1>{article.title}</h1>
{article.published_at && (
<p className="text-sm text-gray-500">
{new Date(article.published_at).toLocaleDateString()}
{article.reading_time ? ` · ${article.reading_time} min read` : ""}
</p>
)}
{article.featured_image && (
<img src={article.featured_image} alt={article.title} />
)}
<Markdown remarkPlugins={[remarkGfm]}>{article.content}</Markdown>
</article>
);
}params is a plain object: read params.slug without await. The prose class needs the @tailwindcss/typography plugin.Start your dev server and open /blog. Your published articles appear, and each one opens at /blog/your-article-slug.
The same endpoints work from any framework. Send your key in the Authorization header on every request.
GET/api/v1/articles?limit=9&offset=0Published articles, newest firstGET/api/v1/articles/{slug}One article by its slugGET/api/v1/articles/search?q=seoSearch titles and excerptsGET/api/v1/tagsAll tags of your siteGET/api/v1/tags/{slug}One tag by its slugGenerate it in your integration settings, then follow the steps above.
Go to Integrations