01 Software

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:

Collectiontitledescriptionimage
productstitlesubtitlethumbnail
poststitleexcerptthumbnail
documentstitlesummary
playliststitledescriptionimage
othertitledescriptionthumbnail

Available on both BrowserClient and ServerClient.

Options

OptionTypeDescription
titlestringFallback when field is empty
descriptionstringFallback when field is empty
siteNamestringog: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.

On this page