Dynamic manifest.json generation based on external parameters #61130
Replies: 4 comments
|
I got a working solution now in which I host the manifest.json files on a cloud storage and load them dynamically by using the generateMetadata() function in my root layout.tsx. |
|
Also looking for a solution to dynamically generate a manifest for different sites in a monorepo |
|
In my case I want to generate a webmanifest dynamically based on query params. // file: app/manifest.webmanifest/route.ts
import { NextRequest, NextResponse } from "next/server";
export const GET = (request: NextRequest) => {
const searchParams = request.nextUrl.searchParams;
const tenant = searchParams.get("t");
// your validation and logic...
const manifest = {
// your manifest file content
};
return NextResponse.json(manifest);
}PS: don't forgot to handle cache correctly. |
|
Cool, thanks for the update, i will try this as soon as possible, function to get the url of the manifest based on page parameter similar to your solution. Not having to create a file on s3 is great!! |
Uh oh!
There was an error while loading. Please reload this page.
I can dynamically create the manifest.json file like this
Generate a Manifest file
is it possible to inject any information into the manifest.ts metadata route? I would like to change name and icon of the manifest based on the user that creates the request.
I can access the cookies but they seem to be empty and there doesn't seem to be any other props that can be accessed.
All reactions