Next.js blog
Build a high-performance blog on your Next.js App Router site with our ready-made scaffold and read client.
Build a blog in an existing Next.js App Router project using server-side article synchronization. You do not need a special branded npm package: use your database or content store, native server utilities and standard Next.js routes.
#Prepare the connection
Open Settings → Publishing and choose the API-based publishing setup for your website. Generate the website key and copy the exact API base address from the authenticated instructions. Follow the Article API guide.
Store AI_GROWTH_API_KEY and AI_GROWTH_API_BASE as server-only environment variables. Never add NEXT_PUBLIC_ to either value. Use import "server-only" in modules that read the key. Keep the key out of client components, browser bundles and logs.
#Synchronize into your own storage
- Schedule a server job to list articles with
limit=50and increasingoffsetvalues.
- Fetch each full article by its ID.
- Validate and sanitize its body, schema and metadata.
- Upsert by language and slug into your database or content files. Preserve intentional editorial overrides.
- Trigger revalidation for the blog list, changed article, related category/tag pages and sitemap only after the save succeeds.
Do not call the rate-limited article API for each page view. Your public routes should read your local store. Use a job lock, bounded retries and clear error reporting so a failed import does not replace a valid page with empty content.
#Create the routes
| Route or file | Purpose |
|---|---|
app/blog/page.tsx | List published articles from local storage |
app/blog/[slug]/page.tsx | Render one published article |
app/blog/tag/[tag]/page.tsx | Optional tag archive |
app/sitemap.ts | Include published canonical URLs and real modification dates |
Use Server Components for article reads and initial HTML. For an unknown or unpublished slug call notFound(). Set the document language correctly and keep translations on distinct URLs. Do not render the same article at several competing canonical paths.
#Metadata and structured data
Use generateMetadata for the title, description, canonical URL and social image. Render sanitized article HTML as content, not executable markup. Validate jsonLd and faqJsonLd, then serialize JSON-LD safely in the page head or supported metadata flow. Avoid duplicate Article or FAQ schema already emitted by your theme.
When using next/image, configure remotePatterns for the exact trusted image hosts you actually use. Do not allow every remote hostname. If you copy assets locally, use durable storage and keep the saved image URL with the article.
#Match your design
Create reusable blog list and detail templates. Style headings, lists, TL;DR, sources, tables, code and images; test their mobile width. Add a blog link to your navigation. Article HTML supplies semantics; your own theme controls the appearance.
#Verify the integration
Check a published article, an unknown slug, the HTML source, canonical metadata and sitemap. Trigger the same sync twice and confirm that it updates one record rather than duplicating posts. Check that the API key never appears in page source or browser requests.
#Troubleshooting
- No new articles: Confirm the scheduled job runs and revalidation succeeds.
- Missing content: Retrieve full records, not list summaries.
- Image errors: Check the exact image host allowlist and source accessibility.
- Duplicate posts: Fix the language/slug upsert constraint.
- Authentication failure: Rotate the key securely and update every consumer.
For a setup that does not require adding routes, consider Blog Hosting.