pages are SSG but should be dynamic
Answered
B33fb0n3 posted this in #help-forum
B33fb0n3OP
Hey, I created mutliple pages and some of them are dynamic and some not (https://ibb.co/j3j0CYR). Now I tried to use a parallel route inside this admin dashboard (https://ibb.co/c2v5sfB) and everything works fine on localhost.
When I push it to vercel I get [this error](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929).
I followed the guide [here](https://nextjs.org/docs/messages/app-static-to-dynamic-error) and used
(the generateStaticParams shouldn't affect this behavior, because there are pages that are dynamic without using the
How am I able to make my route dynamic?
When I push it to vercel I get [this error](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929).
I followed the guide [here](https://nextjs.org/docs/messages/app-static-to-dynamic-error) and used
export const dynamic = 'force-dynamic'. The result is the same: statically generated pages...(the generateStaticParams shouldn't affect this behavior, because there are pages that are dynamic without using the
export const dynamic...How am I able to make my route dynamic?
Answered by Ray
I got it build on vercel with 14.1 by adding
export const dynamic = "force-dynamic"; to admin/layout.tsx107 Replies
@B33fb0n3 Hey, I created mutliple pages and some of them are dynamic and some not (https://ibb.co/j3j0CYR). Now I tried to use a parallel route inside this admin dashboard (https://ibb.co/c2v5sfB) and everything works fine on localhost.
When I push it to vercel I get [this error](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929).
I followed the guide [here](https://nextjs.org/docs/messages/app-static-to-dynamic-error) and used export const dynamic = 'force-dynamic'. The result is the same: statically generated pages...
(the generateStaticParams shouldn't affect this behavior, because there are pages that are dynamic without using the export const dynamic...
How am I able to make my route dynamic?
since you are using ppr, I think you could use
unstable_noStore on a component to make it dynamic@Ray since you are using ppr, I think you could use `unstable_noStore` on a component to make it dynamic
B33fb0n3OP
are there other ways then using unstable_noStore, beccause it's a production app
@B33fb0n3 are there other ways then using unstable_noStore, beccause it's a production app
maybe disable ppr then, it is still experimental
B33fb0n3OP
you mean by setting this to false?
Currently this
const nextConfig = {
experimental: {
ppr: true, <-------
},
}Currently this
ppr: true is not inside my nextConfig@B33fb0n3 you mean by setting this to false?
const nextConfig = {
experimental: {
ppr: true, <-------
},
}
Currently this ``ppr: true`` is **not** inside my nextConfig
oh I thought the page are partial rendering
B33fb0n3OP
where can I check that?
Because it's an experimental feature and my app is a production app, I haven't looked into PPR yet :/
@B33fb0n3 Hey, I created mutliple pages and some of them are dynamic and some not (https://ibb.co/j3j0CYR). Now I tried to use a parallel route inside this admin dashboard (https://ibb.co/c2v5sfB) and everything works fine on localhost.
When I push it to vercel I get [this error](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929).
I followed the guide [here](https://nextjs.org/docs/messages/app-static-to-dynamic-error) and used export const dynamic = 'force-dynamic'. The result is the same: statically generated pages...
(the generateStaticParams shouldn't affect this behavior, because there are pages that are dynamic without using the export const dynamic...
How am I able to make my route dynamic?
the error is
you are using the value of
/de/landingpages/wishvideo/admin/09bf17d5-8b96-4319-b853-abc2cda85644, reason: searchParams.langyou are using the value of
searchParams.lang in /[lang]/landingpages/wishvideo/admin/[id]@B33fb0n3 and then it's automatically ppr?
no, not ppr, I was wrong, I mix the icon of ssg and ppr
B33fb0n3OP
oh ok. The page inside the @modal/[id] is a Client Component. With the params and searchparams it should be dynamic 🤔
It looks like:
'use client'
export default function ConfirmDialog({params: {id}, searchParams: {lang, status, email}}) {
const {toast} = useToast();
...
}@B33fb0n3 oh ok. The page inside the @modal/[id] is a Client Component. With the params and searchparams it should be dynamic 🤔
I think the route is dynamic as long as you don't set the
dyanmicParams to falsesince you using
generateStaticParams on the [lang], so it show the page is SSG on the build logB33fb0n3OP
ohh so the /admin/ is SSG, but the @modal is dynamic. And that's not possible, right?
it is dynamic now I think?
@B33fb0n3 ohh so the /admin/ is SSG, but the @modal is dynamic. And that's not possible, right?
are you getting 404 when navigating to
admin/[id]?@Ray it is dynamic now I think?
B33fb0n3OP
it's currently static, because the lang variable is pre defined and there are no other variables in it:
@Ray are you getting 404 when navigating to `admin/[id]`?
B33fb0n3OP
I don't.
I get a 500 | Internal Server Error
I get a 500 | Internal Server Error
you should create
admin/[id]/page.tsxand return null
B33fb0n3OP
that works! No error. But also the "old page" won't be rendered. Inside my layout the modal will be rendered on top of the page. When I go to admin/[id], the modal isn't on top. Normally a parallel route is on top of another 🤔
on top? I think you need to set it with css?
B33fb0n3OP
normally the parallel route would be rendered "inside" the same route. So by navigating to /admin the page.js should be rendered (modal shouldn't be rendered, because there is no matching route). When I navigate to /admin/[id] there is a matching route and
{children} and also the {modal && modal} should be rendered (because there is a matching route)when adding the [id] as own route this "own route" will be rendered
@B33fb0n3 when adding the [id] as own route this "own route" will be rendered
yea, so you should do
return null for your caseyou want to render a /admin/[id] in a modal right?
B33fb0n3OP
currently it looks like that:
export default function IdPage() {
return null
}@Ray you want to render a /admin/[id] in a modal right?
B33fb0n3OP
yes. I am on the /admin page and there are Link-Components to /admin/[id]. When clicking a link a modal (on the same page) will open (through route) and you can do stuff inside the modal. The page in the background stays the same
B33fb0n3OP
It is. It's easily possible with clientside states, but I don't want to use them
When I navigate to /admin/[id] there is a matching route and {children} and also the {modal && modal} should be rendered (because there is a matching route)because you didn't have
/admin/[id] which is the entry point of the parallel route. so you will get 404 with just @modal/admin/[id]and the reason why you get 500 is, you are trying to use searchParams.lang on a 404 route
B33fb0n3OP
it seems like what you try to tell me makes sense, but I currently can't follow you... are you able to write it a little differently?
@B33fb0n3 it seems like what you try to tell me makes sense, but I currently can't follow you... are you able to write it a little differently?
a parallel route require a route with one or more slot and you just created the slot without the route
if the route doesn't exist, it return 404.
B33fb0n3OP
oh ok. I thought that only applied to intercepting routes?
I just followed [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples) and couldn't find a route for example for "login" or for "signup" (in [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples)) that is defined twice
The default.js handles the content when there is no route available
I just followed [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples) and couldn't find a route for example for "login" or for "signup" (in [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples)) that is defined twice
The default.js handles the content when there is no route available
@B33fb0n3 oh ok. I thought that only applied to intercepting routes?
I just followed [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples) and couldn't find a route for example for "login" or for "signup" (in [this example](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#examples)) that is defined twice
The default.js handles the content when there is no route available
oh the default.js only handle unmatched slots not route
@Ray oh the default.js only handle unmatched slots not route
B33fb0n3OP
Oh, I see. How to get this working (I can just show the local result, because on localhost it works and on vercel not): https://youtu.be/fdsgIpKbCiU
@Ray how does it look like on vercel?
B33fb0n3OP
when I am at /admin it looks the same and when I navigate to a /admin/[id] I get the 500 Internal Server Error Page. The error in the background is [this](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929)
@B33fb0n3 when I am at /admin it looks the same and when I navigate to a /admin/[id] I get the 500 Internal Server Error Page. The error in the background is [this](https://paste.gg/p/B33fb0n3/30ad8ff9aaa14edf955027f0af9d3929)
check the build log on vercel and see if you have the route for /admin/[id]
@Ray check the build log on vercel and see if you have the route for /admin/[id]
B33fb0n3OP
I just checked and can confirm the route
/[lang]/landingpages/wishvideo/admin/[id] has been built@B33fb0n3 I just checked and can confirm the route /[lang]/landingpages/wishvideo/admin/[id] has been built
I just test building on vercel and got this error
Unable to find lambda for route: /[lang]/admin/defaultit build fine if I don't static generate for the
lang@Ray I just test building on vercel and got this error
`Unable to find lambda for route: /[lang]/admin/default`
B33fb0n3OP
did you also added the staticParams functions (to the root layout)?
export async function generateStaticParams() {
return i18n.locales.map((locale) => ({lang: locale}))
}@B33fb0n3 did you also added the staticParams functions (to the root layout)?
jsx
export async function generateStaticParams() {
return i18n.locales.map((locale) => ({lang: locale}))
}
yes but it only build when i remove it on vercel
B33fb0n3OP
lol
so you may want to contact vercel support
B33fb0n3OP
ok, I will do that. Thanks ðŸ‘
@B33fb0n3 ok, I will do that. Thanks ðŸ‘
yea, try without
generateStaticParams and see if it work@Ray yea, try without `generateStaticParams` and see if it work
B33fb0n3OP
it works without it. On the other hand I have so many sites that can be easily build statically (and also should) so I need that. Maybe there is some way to optout specific routes from it like we saw with force-dynamic or noStore which both don't work..
@B33fb0n3 it works without it. On the other hand I have so many sites that can be easily build statically (and also should) so I need that. Maybe there is some way to optout specific routes from it like we saw with force-dynamic or noStore which both don't work..
Unable to find lambda for route: /[lang]/admin/default this is the problemB33fb0n3OP
are you able to create a web version of your code? I can take a look what I have differently
B33fb0n3OP
command not found
do I need to install something?
I can offer you one of these:
I can offer you one of these:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},@Ray yes
npm i -g vercel
B33fb0n3OP
build complete. The build progress works fine. No errors
@B33fb0n3 build complete. The build progress works fine. No errors
does the page work?
it can build with 14.0.4
are you using 14.0.4?
@Ray does the page work?
B33fb0n3OP
yea it works
@Ray are you using 14.0.4?
B33fb0n3OP
currently I am using
"next": "14.1.0",B33fb0n3OP
that doesn't. The page itself works fine, but not the switch with the parallel route
I have no problem with 14.0.4 on vercel
B33fb0n3OP
did you also added the staticParams functions (to the root layout)?
export async function generateStaticParams() {
return i18n.locales.map((locale) => ({lang: locale}))
}look like this with 14.1
B33fb0n3OP
and inside your /admin/default is the parallel route in the layout?
B33fb0n3OP
and your @modal/[id] also access the searchparams?
@B33fb0n3 and your @modal/[id] also access the searchparams?
yea
export default function Page({
params,
searchParams,
}: {
params: { id: string };
searchParams: { q: string };
}) {
return (
<div>
modal {params.id} <br /> searchParams {searchParams.q}{" "}
</div>
);
}try 14.0.4 if you are on 14.1
it is not working for me with 14.1 on vercel
B33fb0n3OP
The red page will be rendered (in the background) when navigating to an id and the green one, when you haven’t chosen one, correct?
B33fb0n3OP
Yea
And when navigating to /admin/[id] the red outlined page.js is in the background, right?
the red one only render when you are on
/[lang]/admin/[id]@B33fb0n3 And when navigating to /admin/[id] the red outlined page.js is in the background, right?
no it won't render when you are on
/[lang]/admin/[id]@Ray the red one only render when you are on `/[lang]/admin/[id]`
B33fb0n3OP
Ok, if I do it the same (with the extra route for [id] outside the modal) it also works for me, but it changes the background. In my video (localhost) you can see, that the background doesn’t change
it only render when you are on
/[lang]/adminI think you should use intercepting route if you want
/[lang]/admin in the backgroundor you have to move
@modal to the root@Ray I think you should use intercepting route if you want `/[lang]/admin` in the background
B33fb0n3OP
I think these kind of routes are kinda confusing for me. I tried to rebuild the example and tried to make it dynamic but I guess it’s not that easy as it sounds like :/
@Ray or you have to move `@modal` to the root
B33fb0n3OP
to the root?
app/@modalB33fb0n3OP
Isn’t it the same problem?
app/@modal/[id] is dynamic
app/………./admin/ is static
app/@modal/[id] is dynamic
app/………./admin/ is static
no,
app/@modal this is a slotbut I think you want intercepting route if you want the previous page stay in background
@Ray but I think you want intercepting route if you want the previous page stay in background
B33fb0n3OP
an intercepting route? Which route would be intercepted? Because currently there is no own route for a specific id and I haven't planed it yet
I also tried it with
(..)[id] because the [id]-Route isn't in the same folder and got the same error@B33fb0n3 I also tried it with (..)[id] because the [id]-Route isn't in the same folder and got the same error
yeah, that's why I said you should contact vercel support
14.0.4 build fine but not 14.1
14.1 build fine if not generate the params for lang
14.1 build fine on locally with and without the lang params generated
14.1 build fine if not generate the params for lang
14.1 build fine on locally with and without the lang params generated
B33fb0n3OP
I now tried using 14.0.4 but that also doesn't work for me. Same error with "Unable to find ...". I can't contact vercel, because of my current plan
how does your route look like now
I got it build on vercel with 14.1 by adding
export const dynamic = "force-dynamic"; to admin/layout.tsxAnswer
@Ray I got it build on vercel with 14.1 by adding `export const dynamic = "force-dynamic";` to `admin/layout.tsx`
B33fb0n3OP
that's the solution! Good job ðŸ‘
@Ray how does your route look like now
B33fb0n3OP
I first tried the force-dynamic with the intercepting route and it works without errors (building and using) and after that I tried the same with just the modal with [id] and nothing more (https://ibb.co/bbWKMyS) and that also works without problems. Working with 14.1.0
I checked the build log and the "dynamic page" is now static lol and with that the searchparams aren't read... 😦
UPDATE:
Fixed the searchparams thing by changing the "lang" variable to "language" and added the intercepting route. Through the intercepting route change the route will be dynamically handled (also through the force-dynamic from the layout) and the intercepting layers the modal on top of the page. The id route just returns null
UPDATE:
Fixed the searchparams thing by changing the "lang" variable to "language" and added the intercepting route. Through the intercepting route change the route will be dynamically handled (also through the force-dynamic from the layout) and the intercepting layers the modal on top of the page. The id route just returns null