manifest.json
在 app
目錄的 根目錄 下新增或生成符合 Web Manifest 規範 的 manifest.(json|webmanifest)
檔案,以便為瀏覽器提供有關您的網頁應用程式的資訊。
靜態 Manifest 檔案
{
"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
檔案。
import { 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',
},
],
}
}
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 物件包含大量選項,這些選項可能會因新的網頁標準而更新。如需所有當前選項的資訊,請參考程式碼編輯器中的 MetadataRoute.Manifest
類型(若使用 TypeScript),或查看 MDN 文件。