DocsPluginsShowcaseReleases
npmStar us on GitHub

Getting Started

IntroductionInstallationProject StructureLayouts and PagesLinking and Navigating

Routing

Folder-Based RoutingFile-Based RoutingDynamic RoutesParallel RoutesIntercepting RoutesCatch-All RoutesMDX & Markdown Pages

Special Files

Loading UIError BoundariesTemplateDefaultNot Found

Data Fetching

LoadersActionsAccessing Route Data

Metadata

Metadata & SEOOpen Graph & TwitterIcons & Favicons

API Routes

API Routes OverviewPlain Function HandlersHono IntegrationDynamic API Routes

Environment Variables

OverviewPrefixes & Client ExposureUsing in API Routes

Styling

CSS OverviewTailwind CSSCSS Modules

Platforms

WebWindowsmacOSLinuxAndroidiOS

Deployment

Deployment OverviewProduction ServerStatic ExportHosting Providers

A native React framework for building cross-platform applications from a single codebase.

Resources

  • Documentation
  • Plugins
  • Showcase
  • Releases

Community

  • GitHub Discussions
  • Reddit
  • Discord
  • LinkedIn

More

  • npm
  • GitHub
  • Issues
  • License

© 2026 Bini Cooperation.

Metadata

Export document.head for site-wide head tags and page-level SEO.

Overview

Bini.js uses the document export for document-level configuration. Export a document object containing a head node tree to configure your site's title, meta tags, scripts, and JSON-LD.

ExportBest forWhere to use
documentRaw head tags, scripts, JSON-LDRoot layout (layout.tsx)
The document export is statically extracted at build time and removed from the client bundle. It is applied during static rendering and injected into the static HTML.

Using document.head

In the root layout, export a document object with a head node tree. All standard head tags, JSON-LD scripts, and initialization scripts go here. This is the pattern used by every Bini.js project.

src/app/layout.tsx
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'WebSite',
  name: 'My App',
}

export const document = {
  head: (
    <>
      <title>My App</title>
      <meta name="description" content="Built with Bini.js" />
      <meta name="theme-color" content="#00CFFF" />

      <link rel="manifest" href="/site.webmanifest" />
      <link rel="icon" type="image/x-icon" href="/favicon.ico" />
      <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />

      <meta property="og:title" content="My App" />
      <meta property="og:description" content="Built with Bini.js" />
      <meta property="og:image" content="/og-image.png" />

      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:creator" content="@your_handle" />

      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
    </>
  ),
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return <>{children}</>
}
document.head is a full JSX node tree. It is serialized into the static HTML. Attributes and children must be static, otherwise they are dropped.

Open Graph

Open Graph tags control previews on Facebook, LinkedIn, and Slack.

src/app/about/page.tsx
export const document = {
  head: (
    <>
      <title>About Us</title>
      <meta property="og:title" content="About Us - My App" />
      <meta property="og:description" content="Learn more about our company" />
      <meta property="og:url" content="https://myapp.com/about" />
      <meta property="og:type" content="website" />
      <meta property="og:site_name" content="My App" />
      <meta property="og:image" content="/og-image.png" />
      <meta property="og:image:width" content="1200" />
      <meta property="og:image:height" content="630" />
    </>
  ),
}

Twitter Cards

Twitter (X) card fields control how links appear in the feed.

src/app/blog/[slug]/page.tsx
export const document = {
  head: (
    <>
      <title>Blog Post</title>
      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:title" content="Blog Post" />
      <meta name="twitter:description" content="A comprehensive guide to Bini.js" />
      <meta name="twitter:creator" content="@your_handle" />
      <meta name="twitter:image" content="/og-image.png" />
    </>
  ),
}

Icons

Add icon links directly to document.head.

src/app/layout.tsx
export const document = {
  head: (
    <>
      <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
      <link rel="icon" type="image/x-icon" href="/favicon.ico" />
      <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    </>
  ),
}

Default Images

Put static assets in public/. Reference them by absolute path in document.head.

public
favicon.ico
apple-touch-icon.png
og-image.png
logo.png
site.webmanifest
Recommended Open Graph size is 1200×630. No extra config - files in public/ are served as-is.

Nested Layouts

For page-specific head tags, you can export document from inner layouts. The nearest document export wins (page first, then the closest layout). Documents are not merged.

app
layout.tsx
page.tsx
blog
layout.tsx
page.tsx
[slug]
page.tsx
/
/blog
/blog/:slug
src/app/blog/layout.tsx
export const document = {
  head: (
    <>
      <title>Blog | My App</title>
      <meta name="description" content="Read the latest articles" />
    </>
  ),
}

How It Works

During vite build, the document export is serialized into the static HTML.

  • document.head: full node tree serialized into the page's head.
  • Nested layouts: the nearest document export is used, not merged.
  • Dynamic routes: head tags are applied per manifest entry, not per concrete URL. Render dynamic tags from your page component if needed.

Complete Example

The root layout uses document.head for the site-wide head. Inner pages can override it with a their own document export.

src/app/layout.tsx
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'WebSite',
  name: 'My App',
}

export const document = {
  head: (
    <>
      <title>My App</title>
      <meta name="description" content="Built with Bini.js" />
      <link rel="icon" href="/favicon.ico" />
      <link rel="manifest" href="/site.webmanifest" />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
    </>
  ),
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return <>{children}</>
}
src/app/blog/[slug]/page.tsx
export const document = {
  head: (
    <>
      <title>Blog Post</title>
      <meta name="description" content="A comprehensive guide" />
      <meta property="og:title" content="Blog Post" />
      <meta property="og:image" content="/og-image.png" />
      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:creator" content="@your_handle" />
    </>
  ),
}

export default function BlogPost() {
  return <h1>Blog Post</h1>
}

Open Graph & Twitter

Control social preview cards.

Icons & Favicons

Set icons and web manifests.

Layouts and Pages

Create your first pages and wrap them in shared layouts.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Deployment

Deploy to Node, Vercel, Netlify, Cloudflare, or Deno, or build native apps in CI.

Installation

Review CLI flags and system requirements.

Was this helpful?
PreviousAccessing Route Data
NextOpen Graph & Twitter

On this page

  • Overview
  • Using document.head
  • Open Graph
  • Twitter Cards
  • Icons
  • Default Images
  • Nested Layouts
  • How It Works
  • Complete Example
Edit this page on GitHub

Metadata

Export document.head for site-wide head tags and page-level SEO.

Overview

Bini.js uses the document export for document-level configuration. Export a document object containing a head node tree to configure your site's title, meta tags, scripts, and JSON-LD.

ExportBest forWhere to use
documentRaw head tags, scripts, JSON-LDRoot layout (layout.tsx)
The document export is statically extracted at build time and removed from the client bundle. It is applied during static rendering and injected into the static HTML.

Using document.head

In the root layout, export a document object with a head node tree. All standard head tags, JSON-LD scripts, and initialization scripts go here. This is the pattern used by every Bini.js project.

src/app/layout.tsx
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'WebSite',
  name: 'My App',
}

export const document = {
  head: (
    <>
      <title>My App</title>
      <meta name="description" content="Built with Bini.js" />
      <meta name="theme-color" content="#00CFFF" />

      <link rel="manifest" href="/site.webmanifest" />
      <link rel="icon" type="image/x-icon" href="/favicon.ico" />
      <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />

      <meta property="og:title" content="My App" />
      <meta property="og:description" content="Built with Bini.js" />
      <meta property="og:image" content="/og-image.png" />

      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:creator" content="@your_handle" />

      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
    </>
  ),
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return <>{children}</>
}
document.head is a full JSX node tree. It is serialized into the static HTML. Attributes and children must be static, otherwise they are dropped.

Open Graph

Open Graph tags control previews on Facebook, LinkedIn, and Slack.

src/app/about/page.tsx
export const document = {
  head: (
    <>
      <title>About Us</title>
      <meta property="og:title" content="About Us - My App" />
      <meta property="og:description" content="Learn more about our company" />
      <meta property="og:url" content="https://myapp.com/about" />
      <meta property="og:type" content="website" />
      <meta property="og:site_name" content="My App" />
      <meta property="og:image" content="/og-image.png" />
      <meta property="og:image:width" content="1200" />
      <meta property="og:image:height" content="630" />
    </>
  ),
}

Twitter Cards

Twitter (X) card fields control how links appear in the feed.

src/app/blog/[slug]/page.tsx
export const document = {
  head: (
    <>
      <title>Blog Post</title>
      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:title" content="Blog Post" />
      <meta name="twitter:description" content="A comprehensive guide to Bini.js" />
      <meta name="twitter:creator" content="@your_handle" />
      <meta name="twitter:image" content="/og-image.png" />
    </>
  ),
}

Icons

Add icon links directly to document.head.

src/app/layout.tsx
export const document = {
  head: (
    <>
      <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
      <link rel="icon" type="image/x-icon" href="/favicon.ico" />
      <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    </>
  ),
}

Default Images

Put static assets in public/. Reference them by absolute path in document.head.

public
favicon.ico
apple-touch-icon.png
og-image.png
logo.png
site.webmanifest
Recommended Open Graph size is 1200×630. No extra config - files in public/ are served as-is.

Nested Layouts

For page-specific head tags, you can export document from inner layouts. The nearest document export wins (page first, then the closest layout). Documents are not merged.

app
layout.tsx
page.tsx
blog
layout.tsx
page.tsx
[slug]
page.tsx
/
/blog
/blog/:slug
src/app/blog/layout.tsx
export const document = {
  head: (
    <>
      <title>Blog | My App</title>
      <meta name="description" content="Read the latest articles" />
    </>
  ),
}

How It Works

During vite build, the document export is serialized into the static HTML.

  • document.head: full node tree serialized into the page's head.
  • Nested layouts: the nearest document export is used, not merged.
  • Dynamic routes: head tags are applied per manifest entry, not per concrete URL. Render dynamic tags from your page component if needed.

Complete Example

The root layout uses document.head for the site-wide head. Inner pages can override it with a their own document export.

src/app/layout.tsx
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'WebSite',
  name: 'My App',
}

export const document = {
  head: (
    <>
      <title>My App</title>
      <meta name="description" content="Built with Bini.js" />
      <link rel="icon" href="/favicon.ico" />
      <link rel="manifest" href="/site.webmanifest" />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
    </>
  ),
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return <>{children}</>
}
src/app/blog/[slug]/page.tsx
export const document = {
  head: (
    <>
      <title>Blog Post</title>
      <meta name="description" content="A comprehensive guide" />
      <meta property="og:title" content="Blog Post" />
      <meta property="og:image" content="/og-image.png" />
      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:creator" content="@your_handle" />
    </>
  ),
}

export default function BlogPost() {
  return <h1>Blog Post</h1>
}

Open Graph & Twitter

Control social preview cards.

Icons & Favicons

Set icons and web manifests.

Layouts and Pages

Create your first pages and wrap them in shared layouts.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Deployment

Deploy to Node, Vercel, Netlify, Cloudflare, or Deno, or build native apps in CI.

Installation

Review CLI flags and system requirements.

Was this helpful?
PreviousAccessing Route Data
NextOpen Graph & Twitter

On this page

  • Overview
  • Using document.head
  • Open Graph
  • Twitter Cards
  • Icons
  • Default Images
  • Nested Layouts
  • How It Works
  • Complete Example
Edit this page on GitHub