Confusion with generateStaticParams | Next 14.1.4
Unanswered
Naeemgg posted this in #help-forum
NaeemggOP
to use dynamic routes with tauri we need to use
My question is how to generate Params like these??
I tried generating many ways but still ended up getting this error
What is the problem here??
generateStaticParams, It was working fine with one params /users/[userId] I was generating it on page.tsx but now I have to do it like this /users/[userId]/[project]/[projectId]My question is how to generate Params like these??
I tried generating many ways but still ended up getting this error
Server Error
Error: Page "/users/[userId]/[project]/page" is missing param "/users/2/2" in "generateStaticParams()", which is required with "output: export" config.
This error happened while generating the page. Any console logs will be displayed in the terminal window.What is the problem here??
58 Replies
@Naeemgg to use dynamic routes with tauri we need to use `generateStaticParams`, It was working fine with one params `/users/[userId]` I was generating it on `page.tsx` but now I have to do it like this `/users/[userId]/[project]/[projectId]`
My question is how to generate Params like these??
I tried generating many ways but still ended up getting this error
ts
Server Error
Error: Page "/users/[userId]/[project]/page" is missing param "/users/2/2" in "generateStaticParams()", which is required with "output: export" config.
This error happened while generating the page. Any console logs will be displayed in the terminal window.
What is the problem here??
try generating them on
/users/[userId]/[project]/[projectId]/page.tsx/users/[userId]/[project]/[projectId]/page.tsx
export async function generateStaticParams() {
return [
{ userId: '1', project: '1', projectId: '1' },
{ userId: '2', project: '2', projectId: '2' }
]
}Now unable to even goto /users/[userId]
ðŸ˜
ðŸ˜
@Naeemgg Now unable to even goto /users/[userId]
ðŸ˜
oh you need to export a generateStaticParams in /users/[userId]/page.tsx too
NaeemggOP
in all nested route I need to export correct?
//users/[userId]/page.tsx
export async function generateStaticParams() {
return [
{ userId: '1' },
{ userId: '2' }
]
}@Naeemgg in all nested route I need to export correct?
yes every page.tsx
NaeemggOP
in [userId] I need to return userIDs
yes
NaeemggOP
in
userIds + project or just project??
[userId]/[project]/page.tsxuserIds + project or just project??
I tried this
return [{ userId: "blabla",
project:"vercel"
},{...})its not working giving the same error
@Naeemgg its not working giving the same error
what is the error now?
NaeemggOP
Server Error
Error: Page "/users/[userId]/[project]/page" is missing param "/users/2/1" in "generateStaticParams()", which is required with "output: export" config.
This error happened while generating the page. Any console logs will be displayed in the terminal window.tried this also
return [{project:"vercel"
},{...})@Naeemgg ts
Server Error
Error: Page "/users/[userId]/[project]/page" is missing param "/users/2/1" in "generateStaticParams()", which is required with "output: export" config.
This error happened while generating the page. Any console logs will be displayed in the terminal window.
do you have { userId: 2, project: 1} in the array?
@Naeemgg for(i=0;i<10;i++)
can you show the code on generateStaticParams?
NaeemggOP
const users = []
for(let i=0; i<10;i++){
racks.push({id:i.toString()})
}
return users.map((user) => ({
userId: user.id,
project:user.id
}))NaeemggOP
/user/[usderId]
export const generateStaticParams = async()=>{
const users = []
for(let i=0; i<10;i++){
users.push({id:i.toString()})
}
return users.map((user) => ({
userId: user.id,
}))
}@Ray what is `racks` here?
NaeemggOP
ohh sorry it was users
@Naeemgg ohh sorry it was users
ok can you show the generateStaticParams on /users/[userId]/[project]/page?
NaeemggOP
yes
export const generateStaticParams = async()=>{
const users = []
for(let i=0; i<10;i++){
users.push({id:i.toString()})
}
return users.map((user) => ({
//userId: user.id,
project:user.id
}))
}tried commenting and uncommenting stuff
still getting the same error
@Naeemgg ts
export const generateStaticParams = async()=>{
const users = []
for(let i=0; i<10;i++){
users.push({id:i.toString()})
}
return users.map((user) => ({
//userId: user.id,
project:user.id
}))
}
return users.map((user) => ({
userId: user.id,
project:user.id
}))try this
@Naeemgg already tried
what is the error message?
😫😫
do you have some link go to /users/2/1?
NaeemggOP
yes
return users.map((user) => ({
userId: user.id,
project:user.id
}))this doesn't generate
/users/2/1this generate
/users/0/0
/users/1/1
/users/2/2
/users/3/3
....
/users/0/0
/users/1/1
/users/2/2
/users/3/3
....
you need to add {userId: 2, project: 1 } in the array
But I have links
let me show it to you
Ahh its too big component
I have on first page 10 users with
<Link href={'/users/${userId}'}>{username}</Link>After clicking on users I can see there projects and click on them to see different project IDs
Are you getting my point or have I lost you?
NaeemggOP
@Ray
@Naeemgg Are you getting my point or have I lost you?
so have you got it working?
NaeemggOP
Noooooo
Tried many many things but still not working
@Naeemgg Tried many many things but still not working
West African Lion
Having quite a similar issue with Next.js 14.2.2.
Have you maybe found a solution?
Have you maybe found a solution?
@West African Lion Having quite a similar issue with Next.js 14.2.2.
Have you maybe found a solution?
NaeemggOP
I got to know one thing about Tauri which is it hates SSR so if you want to use searchParams or params my humble advice would be to go with react
West African Lion
I have tried digging in, and...
When I set:
in my
When I set:
export const dynamicParams = false;in my
page.tsx, I get in the first (nested) if-statement:staticPaths = pathsResult.staticPaths;
fallbackMode = pathsResult.fallbackMode;
hasFallback = typeof fallbackMode !== "undefined";
if (this.nextConfig.output === "export") {
const page = components.page;
if (fallbackMode !== "static") {
throw new Error(`Page "${page}" is missing exported function "generateStaticParams()", which is required with "output: export" config.`);
}
const resolvedWithoutSlash = (0, _removetrailingslash.removeTrailingSlash)(resolvedUrlPathname);
if (!(staticPaths == null ? void 0 : staticPaths.includes(resolvedWithoutSlash))) {
throw new Error(`Page "${page}" is missing param "${resolvedWithoutSlash}" in "generateStaticParams()", which is required with "output: export" config.`);
}
}Basically,
However, if I set it to
(Also, doing so is a hard error when running
fallbackMode is set to false and seems to correspond to the value of dynamicParams.However, if I set it to
"static" - which I shouldn't according to the documentation - I get in the next if-statement.(Also, doing so is a hard error when running
npm run build)