N Next.js 中文
原文 ↗
Next.js 文档/API Reference / API 参考/Metadata Files / 元数据文件

manifest.json

manifest.json 文件的 API 参考。

更新于 2026-03-03Next.js 16.4.6

在 app 目录的根目录中添加或生成符合 Web 应用清单规范 的 manifest.(json|webmanifest) 文件,以便为浏览器提供有关你的 Web 应用的信息。

静态 Manifest 文件

app/manifest.json | app/manifest.webmanifestjson
{
  "name": "My Next.js Application",
  "short_name": "Next.js App",
  "description": "An application built with Next.js",
  "start_url": "/"
  // ...
}

生成 Manifest 文件

添加一个返回 Manifest 对象 的 manifest.js 或 manifest.ts 文件。

须知:manifest.js 是一种特殊的路由处理器,默认会被缓存,除非它使用了 请求时 API 或 动态配置 选项。

TypeScript

app/manifest.tsts
import type { MetadataRoute } from 'next'

export default function manifest(): MetadataRoute.Manifest {
  return {
    name: 'Next.js App',
    short_name: 'Next.js App',
    description: 'Next.js App',
    start_url: '/',
    display: 'standalone',
    background_color: '#fff',
    theme_color: '#fff',
    icons: [
      {
        src: '/favicon.ico',
        sizes: 'any',
        type: 'image/x-icon',
      },
    ],
  }
}

JavaScript

app/manifest.jsjs
export default function manifest() {
  return {
    name: 'Next.js App',
    short_name: 'Next.js App',
    description: 'Next.js App',
    start_url: '/',
    display: 'standalone',
    background_color: '#fff',
    theme_color: '#fff',
    icons: [
      {
        src: '/favicon.ico',
        sizes: 'any',
        type: 'image/x-icon',
      },
    ],
  }
}

Manifest 对象

manifest 对象包含大量选项,这些选项可能会因新的 Web 标准而更新。如需了解所有当前选项,如果你使用 TypeScript,请参阅代码编辑器中的 MetadataRoute.Manifest 类型,或查看 MDN 文档。