SSG with client components
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
Hey! Can I use SSG work server pages that return nested client components?
Currently examples only show react components that don't use state. However, I have a server rendered page with a react client component utilizing state. Will nextjs prerender that client component properly? Or can SSG only work with static html components, that do not use state? Example code:
Whenever I build, it gives an out of memory error. Is this caused by the client component or just vercel compute limitations?
Currently examples only show react components that don't use state. However, I have a server rendered page with a react client component utilizing state. Will nextjs prerender that client component properly? Or can SSG only work with static html components, that do not use state? Example code:
export const dynamicParams = false;
export const revalidate = false;
type Props = {
params: { addressSlug: string };
searchParams: { [key: string]: string | string[] | undefined };
};
export async function generateStaticParams(): Promise<Props['params'][]> {
const addressSlugs = (await db.property.findMany({
// Limit ISR to only California addresses due to vercel build error memory, for now.
where: { address: { state: 'CA' }, addressSlug: { not: null } },
select: { addressSlug: true }
})) as { addressSlug: string }[];
return addressSlugs;
}
export default async function Page({
params: { addressSlug }
}: Props) {
const decodedAddressSlug = decodeURIComponent(addressSlug);
const { propertyId, formattedAddress, missingFieldsSchemaString } =
await api.property.getPropertySchemaToFill.query({
addressSlug: decodedAddressSlug
});
return (
// Client component is react component. It has useState and useEffect inside.
<ClientComponent
propertyId={propertyId}
formattedAddress={formattedAddress || ''}
missingFieldsSchemaString={missingFieldsSchemaString}
/>
);
}Whenever I build, it gives an out of memory error. Is this caused by the client component or just vercel compute limitations?
4 Replies
Brown bearOP
Brown bear
Brown bearOP
Unfortunately, vercel builds are unrelated to vercel functions, which will not solve the problem. The problem lies with the machine's physical RAM capacity, which the docs do not have a solution for even if upgrading to the pro plan.
https://vercel.com/docs/deployments/troubleshoot-a-build#build-container-resources
https://vercel.com/docs/deployments/troubleshoot-a-build#build-container-resources
Has anyone experienced this issue with SSG? Even when removing the client component and stripping the page to barebones html, it overflows the RAM.