Metadata
SEO metadata helper for Next.js
Metadata
Automatically generates Next.js Metadata objects from collection documents.
Basic Usage
import { createServerClient } from '@01.software/sdk'
const client = createServerClient({ clientKey, secretKey })
// Find by ID → Metadata (throws on 404)
export async function generateMetadata({ params }) {
return await client.from('posts').findMetadataById(params.id, {
siteName: 'My Blog',
})
}
// Find by query → Metadata | null
export async function generateMetadata({ params }) {
return await client.from('products').findMetadata(
{ where: { slug: { equals: params.slug } } },
{ siteName: 'My Store' },
) ?? {}
}depth: 1 is applied automatically so image relations are populated. Per-collection field mapping is built-in:
| Collection | title | description | image |
|---|---|---|---|
| products | title | subtitle | thumbnail |
| posts | title | excerpt | thumbnail |
| documents | title | summary | — |
| playlists | title | description | image |
| other | title | description | thumbnail |
Available on both BrowserClient and ServerClient.
Options
| Option | Type | Description |
|---|---|---|
title | string | Fallback when field is empty |
description | string | Fallback when field is empty |
siteName | string | og:site_name value |
Image Size Selection
When sizes['1536'] exists on the image, it is preferred for OG images (closest to the 1200px OG standard). Falls back to the original url otherwise.