Build Time Pre Render Error
Answered
rkstlohchab posted this in #help-forum
398 Replies
@rkstlohchab <@755810867878297610>
Im getting prebuild error
Does it work fine with npm run Dev?
yes
it is working fine with run dev
i think the problem is that i am not using async await for data
or is it something else
Can you send full error like also above
@rkstlohchab <@755810867878297610>
Im getting prebuild error
dont put your logic inside your page.tsx
if this is rsc try forcing that route to dynamic rendering
could be that on build time your api is not accessible
@gin if this is rsc try forcing that route to dynamic rendering
can u suggest some docs about it
Answer
export const dynamic = 'force-dynamic'put this in your page.tsx
@rkstlohchab <@755810867878297610>
Im getting prebuild error
your next version?
let me try
@"use php" can u tell exactly what to write here i tried but its not working
"use client";
export default function Page() {
// Fetch the list of expertise entries
const blogList = useQuery(api.blog.getBlog);
const router = useRouter();
if (!blogList) {
return <Loader />;
}
const handleCardClick = (blogId: string) => {
router.push(`/blog/${blogId}`);
};
return (
<div className="lg:px-[120px] lg:py-[30px] max-sm:px-10 max-sm:py-5">
<h1 className="w-full text-start text-2xl my-5">Our Expertise</h1>
<p>
Our main goal is to make a real difference by adding value to society.
</p>
<Separator className="my-5" />
<AccordinMy />
<Separator className="my-5" />
{blogList?.map((blog) => (
<Card
key={blog._id}
className=" m-0 p-0 border-none shadow-none inline-block "
onClick={() => handleCardClick(blog._id)}
>
<CardHeader className="gap-2 lg:mr-10 lg:my-10 max-sm:mt-8">
<Image src={blog.image} alt="abc" width={350} height={210} className="w-[350px] h-[210px]"/>
<CardTitle className="font-normal">{blog.title}</CardTitle>
<CardDescription className="">{blog.description.split(' ').slice(0, 3).join(' ')}</CardDescription>
</CardHeader>
</Card>
))}
</div>
);
}can you send your
page.tsx file?"use client"
import Blog from "@/components/blog"
import Footer from "@/components/Footer"
import Hero from "@/components/Hero"
import Loader from "@/components/Loader"
import SecondSec from "@/components/SecondSec"
import ThirdSec from "@/components/ThirdSec"
import { Separator } from "@/components/ui/separator"
import { useState, useEffect } from "react"
const Page = () => {
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const timer = setTimeout(() => {
setIsLoading(false);
}, 3000);
return () => clearTimeout(timer);
}, []);
if(isLoading) {
return <Loader />
}
return (
<div className="">
<Hero />
<SecondSec />
<ThirdSec />
<Separator className="my-10" />
<Blog />
<Footer />
</div>
)@"use php" Imports?
let me send
"use client";
import { useQuery, useMutation } from "convex/react";
import { api } from "@/../convex/_generated/api";
import { Id } from "../../../convex/_generated/dataModel";
import Image from "next/image";
import { useRouter } from "next/navigation";
import { Separator } from "@/components/ui/separator";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import Loader from "@/components/Loader";
import AccordinMy from "@/components/expertiseAccordin";can you remove
useQuery, and see if the build works?why would this be issue
do the thing i told u
@gin this is your page.tsx
this is my expertise.tsx
@gin then u can export dynamic
i didnt understood how to use dynamic
@rkstlohchab this is my expertise.tsx
why is it called Page xD
show me your page.tsx
where the error occurs
bcoz its app router
this is your page.tsx
??
do this
bcoz the convex wont work
is useQuery a client or a server library?
if it a server library, then yes, he's right
@"use php" is useQuery a client or a server library?
it is convex backend as a service syntax
for retreiving data from db
just like mongo
Then yes, he's right
@rkstlohchab Click to see attachment
removed use client from the file
now useRouter is casuing error
bcoz it need use client
tried removing use client from the blog page.tsx
@"use php"
@rkstlohchab removed use client from the file
Put it in a different file
bro put what in diff file ?
use client ?
@rkstlohchab Click to see attachment
how can i put this in other file
should i give u live share link?
@"use php"
Umm, no, My wifi is currently down, and I'm on mobile data, so can't
Create a client file, which accepts blogPosts
in page.tsx, fetch the data using await, and use the client component and pass it there
you got it right, now move the useQuery to the
page.tsxand pass it
accept a prop
blogPosts on page@"use php" and pass it
pass it to?
client component
@"use php" client component
?like this
now the blog will render and other will cause error right?
Its props, so you need to add a curcly brances around
blogPostyou should be good to go then
@"use php" you should be good to go then
let me check
and you can directly return the loader in the page.tsx ig
await it maybe
if its needed to await, await it
does it work on dev?
@"use php" does it work on dev?
it does perfectly
I'm not familiar much with convex, like I've never used it. So I don't think I can help. You can try stackoverflow, or wait for a response from someone with experience with convex
if you can, try to replace useContext with some static data
for sake of testing
@rkstlohchab whats your anydesk
code
yeah its laggy
@gin let me give you live share
@gin
ill do that
wait
just keep my website structure intact brother okay
try to build
@rkstlohchab
wait is it fixed?
i see errors
nice
can u start a new terminal
sure
done
whats the error?
just this
can u reload the page
f5
reload now
everything seems to be working
but why terminal is showing error?
@gin and can u also sum of what u did
everything good in terminal now too
still showing error?
working
ok good
are u reloading the page?
reload and go to /expertise
and bro
one thing
the loader component is neccessary while loading website
@gin its avail on every page but homepage is not showing
only homepage?
go on /expertise
is expertise working?
reload
yes
its working
now go to home
wokring
wait
but
/500 and loader issue
are u on home
reload
done
still same
btw
if 500 is showing why the website is not crashing @gin
fixed? @rkstlohchab
no @gin
website id able to load data
but terminal is showing 500
why so ?
and loader not showing on homepage
showing now?
not showing
now?
no
is the spinner here text showing
okyy
switch routes
can u swtich around
no issues right and u see the "123" on every page where the loader is
@rkstlohchab Click to see attachment
this is projects
is it this?
do u see the alert
i do
on home
ok wait
hello?!
wait a sec
what do u see now
is it fixed
can u just make everything back to normal let me try
@gin is it fixed
it is on /expertise
and
/
/about
/about
on home?
shows
no loader
did u even use loader on homepage im asking?
like u did on /expertise /project
yeah
/about
check this page
there is no loader in about
okay
cool so its fixed
the issue was the library u was using for the loader
i looked at their docs and just used the css version
oh ohkay
terminal is okay too
but
homepage is still not showing loader
whats the reason
for that
uhh
for the loader not showing in /?
i found the issue
check now
not working yet /
@gin
i think
u are
trying
to load the loader in
blog.tsx
but that file is for only /blog
it wont render loader on /
wait are u rendering the same thing in /blog
are u trying to render the content from blog in home
aswell?
yeaaa
ahhhhhhhhhhhhhhhhhhh
i made a
blog
yes wait
component
and
i am rendering it on
/
/expertise
/expertise
and /blogs too
btw
u just copied the client code in component and rendered it on page.tsx of routes right
that solved the build issue? @gin
okayy
soo everything fixed
alr go on
@gin
did u delete blog.tsx
the one with lowercase
just let me add loader on homepage
nope
i did nothing
while u was working
let me add loader on homepage first
then ill text you
it is already added
the issue is that vscode is bugging
oh okay
in your
it is telling that there is two blog.tsx but one with Uppercase
approve
done
now build
working
wait
u have a devserver running aswell
u should close that when u are building
working
also the loader?
alr
yep
u can mark my answer as solution
for the prerender
sure
thanks!
