@lztek/blogs-for-vercel-sdk
v0.2.0
Published
Official SDK for integrating Blogs-For-Vercel with Next.js and Vercel
Downloads
205
Maintainers
Readme
@lztek/blogs-for-vercel-sdk
Official SDK for integrating Blogs-For-Vercel with Next.js and Vercel.
Installation
npm install @lztek/blogs-for-vercel-sdkQuick Start
Server Components (Recommended)
import { getBlogPosts } from '@lztek/blogs-for-vercel-sdk/server';
export default async function BlogPage() {
const { posts } = await getBlogPosts({ revalidate: 3600 });
return <BlogList posts={posts} />;
}Client Components
'use client';
import { useBlogPosts } from '@lztek/blogs-for-vercel-sdk/hooks';
export default function BlogList() {
const { posts, isLoading, error } = useBlogPosts();
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
{posts.map(post => <BlogPostCard key={post.id} post={post} />)}
</div>
);
}Environment Variables
Server Components
BLOGS_FOR_VERCEL_API_KEY=your_api_key_here
BLOGS_FOR_VERCEL_BASE_URL=https://blogsforvercel.com # Optional, defaults to productionClient Components
NEXT_PUBLIC_BLOGS_FOR_VERCEL_API_KEY=your_api_key_here
NEXT_PUBLIC_BLOGS_FOR_VERCEL_BASE_URL=https://blogsforvercel.com # OptionalAPI Reference
Server Components
getBlogPosts(options?)getBlogPost(slug, options?)getBlogPostsByTag(tag, options?)revalidateBlogPosts(tag?)
Client Components (Hooks)
Core Client
Documentation
For complete documentation, see INTEGRATION.md
License
MIT
