Installation
Install and configure the AutoBlogWriter SDK in your project.
Installation
The @autoblogwriter/sdk is the official TypeScript SDK for fetching and rendering AutoBlogWriter content in your application.
Prerequisites
- Node.js 18+
- A Next.js 13.4+ project (for Next.js helpers — the core client works anywhere)
- A AutoBlogWriter account with a workspace and API key
Install the SDK
npm install @autoblogwriter/sdkyarn add @autoblogwriter/sdkpnpm add @autoblogwriter/sdkPeer Dependencies
The SDK has optional peer dependencies:
| Package | Required For |
|---|---|
react >= 18 | React components (@autoblogwriter/sdk/react) |
next >= 13.4 | Next.js helpers (@autoblogwriter/sdk/next) |
If you only use the core client, neither is required.
Package Entry Points
The SDK ships multiple entry points for different use cases:
// Core client, types, and utilities
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
// Next.js App Router helpers (server-side)
import { fetchBlogPosts, fetchBlogPost } from "@autoblogwriter/sdk/next";
// React components
import { BlogPost, BlogPostList, Markdown } from "@autoblogwriter/sdk/react";
// Webhook signature verification (server-side)
import { verifyWebhookSignature } from "@autoblogwriter/sdk/revalidate";
// Default styles
import "@autoblogwriter/sdk/styles.css";Environment Variables
Add these to your .env.local file:
# Required
AUTOBLOGWRITER_API_KEY=ba_pk_your_api_key_here
AUTOBLOGWRITER_WORKSPACE_SLUG=your-workspace-slug
# Optional
AUTOBLOGWRITER_API_URL=https://api.autoblogwriter.app # Default API URL
AUTOBLOGWRITER_WORKSPACE_ID=ws_abc123 # Alternative to slug for internal use
SITE_URL=https://yoursite.com # Used for sitemap/robots generation
AUTOBLOGWRITER_REVALIDATE_SECRET=your_webhook_secret # For webhook verification
NEXT_PUBLIC_ANALYTICS_TOKEN=your_token # For analytics proxyWhere to Find Your Credentials
- Log in to the AutoBlogWriter Dashboard.
- Navigate to your workspace Settings.
- Under API Keys, create a new key or copy an existing one.
- Your workspace slug is shown in your workspace URL (e.g.,
app.autoblogwriter.app/workspace/your-slug).
Setup Options
You have two ways to use the SDK:
Option A: Environment-Based (Recommended for Next.js)
The simplest approach — the SDK reads configuration from environment variables automatically:
// No setup file needed — just use the helpers directly
import { fetchBlogPosts } from "@autoblogwriter/sdk/next";
// In any server component:
const { posts } = await fetchBlogPosts();The @autoblogwriter/sdk/next helpers call createAutoBlogWriterFromEnv() internally, which reads AUTOBLOGWRITER_API_KEY, AUTOBLOGWRITER_WORKSPACE_SLUG, and other env vars automatically.
Option B: Manual Client (Framework-Agnostic)
For non-Next.js projects or when you need more control:
// lib/blog.ts
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
export const blog = createAutoBlogWriterClient({
apiUrl: "https://api.autoblogwriter.app",
apiKey: process.env.AUTOBLOGWRITER_API_KEY!,
workspaceSlug: process.env.AUTOBLOGWRITER_WORKSPACE_SLUG!,
});See the Client Reference for all configuration options.
Verify Installation
Run a quick test to make sure everything is wired up:
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
const client = createAutoBlogWriterClient({
apiUrl: "https://api.autoblogwriter.app",
apiKey: process.env.AUTOBLOGWRITER_API_KEY!,
workspaceSlug: process.env.AUTOBLOGWRITER_WORKSPACE_SLUG!,
});
const { posts } = await client.getPosts({ limit: 1 });
console.log("Connected! Found", posts.length, "posts");Next Steps
- Quickstart — Build a full blog page in minutes.
- Client Reference — Explore all client configuration options and methods.