1.1.5 • Published 2 months ago

nextjs-webmanifest v1.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

Next.js Webmanifest helper npm npm type definitions

Simplify adding webmanifest to your web.

Installation

npm install nextjs-webmanifest

Usage

With pages directory

Create app.webmanifest.js file inside your Next.js pages/api directory and use createWebmanifestHandler.

pages/api/app.webmanifest.js

import { createWebmanifestHandler } from 'nextjs-webmanifest'

export default createWebmanifestHandler({
	name: 'My Super Trouper App',
	short_name: 'App',
	start_url: '/',
	display: 'standalone',
	theme_color: '#04a600',
	background_color: '#000000',
	// You can add more: https://developer.mozilla.org/en-US/docs/Web/Manifest
})

Asynchronous

export default createWebmanifestHandler(async (request) => {
	const locale = request.url.substring(1, 3)
	const response = await fetch(`https://example.com/${locale}/manifest.json`)
	const manifest = await response.json()
	return manifest
})

<head>

Don't forget to add <link> to <head> to tell browser where to look for your webmanifest.

<link rel="manifest" href="/api/app.webmanifest" />

With app directory

Create route.js file inside your Next.js app/app.webmanifest directory and use createWebmanifestGET.

app/app.webmanifest/route.js

import { createWebmanifestGET } from 'nextjs-webmanifest'

export const GET = createWebmanifestGET({
	name: 'My Super Trouper App',
	// and more
})

createWebmanifestGET can accept asynchronous function as well.

<head>

Don't forget to add <link> to <head> to tell browser where to look for your webmanifest.

<link rel="manifest" href="/app.webmanifest" />

or

export const metadata: Metadata = {
	manifest: '/app.webmanifest',
}
1.1.5

2 months ago

1.1.4

2 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.1.3

4 months ago

1.1.2

4 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago