Why am I getting prerender errors in Next.js 14 build?

I am encountering an issue when running the next build command on my Next.js 14 application. The build process fails with the following prerendering errors:

I have checked the links provided, but I am still unable to resolve the issue. Could someone please help me understand why these errors are occurring and how I can fix them? Additionally, if there are specific steps or configurations I should be aware of for prerendering pages correctly in Next.js 14, I would appreciate any guidance or resources. Thank you in advance for your assistance!

Error:

Error occurred prerendering page “/”. Read more: https://nextjs.org/docs/messages/prerender-error
Error occurred prerendering page “/categories”. Read more: https://nextjs.org/docs/messages/prerender-error

Export encountered errors on following paths:
/_not-found
/categories/page: /categories
/competition/page: /competition
/page: /

folder strucuture:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>src/app/
/page.tsx
/cateogies/page.tsx
</code>
<code>src/app/ /page.tsx /cateogies/page.tsx </code>
src/app/
       /page.tsx
       /cateogies/page.tsx

app/page.tsx

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"use client";
import BackgroundPhotoFooter from "@/elements/BackgroundPhoto";
import CategoryList from "@/elements/CategoryList";
import Footer from "@/elements/footer";
import { useEffect, useState } from "react";
import { Modal } from "antd/lib";
import { getCategories, getCompetitions } from "@/services/categories";
import { useTranslation } from "next-i18next";
import LoginModule from "@/elements/Login";
import { ICategory } from "@/models/Category";
import { Spin } from "antd";
import { ICompetition } from "@/models/Competition";
import CompetitionList from "@/elements/CompetitionList";
import { Box, Container, Grid, Typography } from "@mui/material";
import ButtonCustom from "@/elements/ButtonCustom";
import Link from "next/link";
import Menu from "@/elements/Menu";
import Header from "@/elements/header";
import Image from "next/image";
import { useKeycloak } from "@/context/KeycloakContext";
export default function Home() {
const { t } = useTranslation("description");
const [categories, setCategories] = useState<ICategory[]>([]);
const [competitions, setCompetition] = useState<ICompetition[]>([]);
const [isLoading, setLoading] = useState(true);
const [isCategoryLoading, setCategoryLoading] = useState(true);
const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedCategory, setSelectedCategory] = useState(0);
const { authenticated, loading: authLoading } = useKeycloak();
const onCategorySelect = (id: number) => {
setSelectedCategory(id);
setCategoryLoading(true);
getCompetitions()
.then((data) => setCompetition(data))
.catch((err) => console.error(err));
setTimeout(() => {
setCategoryLoading(false);
}, 1000);
};
const handleOk = () => {
setIsModalOpen(false);
};
const handleCancel = () => {
setIsModalOpen(false);
};
useEffect(() => {
if (isLoading) {
try {
getCategories()
.then((data) => {
setCategories(data);
setSelectedCategory(data[0].id);
})
.catch((err) => console.error(err));
getCompetitions()
.then((data) => setCompetition(data))
.catch((err) => console.error(err));
} catch (err) {
console.error("errore: " + err);
}
setTimeout(() => {
setLoading(false);
setCategoryLoading(false);
}, 1000);
}
}, [isLoading]);
const exploreAll = (categoryId: number) => {
console.log("Explore category: " + categoryId);
};
if (authLoading) {
return (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100vh",
}}
>
<Spin size="large" />
</div>
);
}
return (
<>
<Header />
<Modal
title=""
open={isModalOpen}
onOk={handleOk}
onCancel={handleCancel}
footer={null}
closable={false}
okButtonProps={{ style: { display: "none" } }}
cancelButtonProps={{ style: { display: "none" } }}
>
<div className="columns-2 ...">
<div>
<Image
loading="lazy"
quality={75}
style={{ marginBottom: "30%" }}
src="/dog.png"
width={200}
height={700}
alt="dog"
/>
</div>
<div>
<Image
loading="lazy"
quality={75}
src="/ui.png"
width={240}
height={60}
alt="photo image"
style={{ marginLeft: "20px", marginTop: "20px" }}
/>
</div>
</div>
</Modal>
<Box
style={{
backgroundImage: `url(${"header.png"})`,
width: "100%",
height: "900px",
backgroundPosition: "center",
backgroundSize: "cover",
backgroundRepeat: "no-repeat",
}}
>
<Container maxWidth="xl">
<Grid
container
spacing={6}
sx={{
pt: 10,
}}
>
<Grid item xs={12} md={6}>
<Box
component="img"
sx={{
mt: 10,
mb: 5,
height: "auto",
width: 300,
}}
alt="IShotIt"
src="/logo.png"
/>
<Typography variant="h1" sx={{ color: "white", mb: 4 }}>
Show The World Your Best Photos.
</Typography>
<Typography variant="h2" sx={{ color: "white" }}>
Recognized Awards and Big Prizes!
</Typography>
</Grid>
<Grid
item
xs={12}
md={6}
sx={{
display: { xs: "none", md: "inline-block" },
}}
>
{authenticated ? <Menu invert={false} /> : <LoginModule />}
</Grid>
</Grid>
</Container>
</Box>
{isLoading ? (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "50vh",
}}
>
<Spin size="large" />
</div>
) : (
<>
{categories != undefined && categories.length > 0 && (
<CategoryList
categories={categories}
onCategorySelect={onCategorySelect}
/>
)}
{isCategoryLoading ? (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "50vh",
}}
>
<Spin size="large" />
</div>
) : (
competitions != undefined &&
competitions.length > 0 && (
<Box>
<CompetitionList competitions={competitions} />
<Box
sx={{
display: "flex",
justifyContent: "center",
mt: 5,
}}
>
<Link href={`/categories?id=${selectedCategory}`} passHref>
<ButtonCustom
text={"Explore All"}
onClick={() => exploreAll(selectedCategory)}
/>
</Link>
</Box>
</Box>
)
)}
</>
)}
<Box sx={{ mt: 10 }} />
<BackgroundPhotoFooter />
<Footer />
</>
);
}
</code>
<code>"use client"; import BackgroundPhotoFooter from "@/elements/BackgroundPhoto"; import CategoryList from "@/elements/CategoryList"; import Footer from "@/elements/footer"; import { useEffect, useState } from "react"; import { Modal } from "antd/lib"; import { getCategories, getCompetitions } from "@/services/categories"; import { useTranslation } from "next-i18next"; import LoginModule from "@/elements/Login"; import { ICategory } from "@/models/Category"; import { Spin } from "antd"; import { ICompetition } from "@/models/Competition"; import CompetitionList from "@/elements/CompetitionList"; import { Box, Container, Grid, Typography } from "@mui/material"; import ButtonCustom from "@/elements/ButtonCustom"; import Link from "next/link"; import Menu from "@/elements/Menu"; import Header from "@/elements/header"; import Image from "next/image"; import { useKeycloak } from "@/context/KeycloakContext"; export default function Home() { const { t } = useTranslation("description"); const [categories, setCategories] = useState<ICategory[]>([]); const [competitions, setCompetition] = useState<ICompetition[]>([]); const [isLoading, setLoading] = useState(true); const [isCategoryLoading, setCategoryLoading] = useState(true); const [isModalOpen, setIsModalOpen] = useState(false); const [selectedCategory, setSelectedCategory] = useState(0); const { authenticated, loading: authLoading } = useKeycloak(); const onCategorySelect = (id: number) => { setSelectedCategory(id); setCategoryLoading(true); getCompetitions() .then((data) => setCompetition(data)) .catch((err) => console.error(err)); setTimeout(() => { setCategoryLoading(false); }, 1000); }; const handleOk = () => { setIsModalOpen(false); }; const handleCancel = () => { setIsModalOpen(false); }; useEffect(() => { if (isLoading) { try { getCategories() .then((data) => { setCategories(data); setSelectedCategory(data[0].id); }) .catch((err) => console.error(err)); getCompetitions() .then((data) => setCompetition(data)) .catch((err) => console.error(err)); } catch (err) { console.error("errore: " + err); } setTimeout(() => { setLoading(false); setCategoryLoading(false); }, 1000); } }, [isLoading]); const exploreAll = (categoryId: number) => { console.log("Explore category: " + categoryId); }; if (authLoading) { return ( <div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "100vh", }} > <Spin size="large" /> </div> ); } return ( <> <Header /> <Modal title="" open={isModalOpen} onOk={handleOk} onCancel={handleCancel} footer={null} closable={false} okButtonProps={{ style: { display: "none" } }} cancelButtonProps={{ style: { display: "none" } }} > <div className="columns-2 ..."> <div> <Image loading="lazy" quality={75} style={{ marginBottom: "30%" }} src="/dog.png" width={200} height={700} alt="dog" /> </div> <div> <Image loading="lazy" quality={75} src="/ui.png" width={240} height={60} alt="photo image" style={{ marginLeft: "20px", marginTop: "20px" }} /> </div> </div> </Modal> <Box style={{ backgroundImage: `url(${"header.png"})`, width: "100%", height: "900px", backgroundPosition: "center", backgroundSize: "cover", backgroundRepeat: "no-repeat", }} > <Container maxWidth="xl"> <Grid container spacing={6} sx={{ pt: 10, }} > <Grid item xs={12} md={6}> <Box component="img" sx={{ mt: 10, mb: 5, height: "auto", width: 300, }} alt="IShotIt" src="/logo.png" /> <Typography variant="h1" sx={{ color: "white", mb: 4 }}> Show The World Your Best Photos. </Typography> <Typography variant="h2" sx={{ color: "white" }}> Recognized Awards and Big Prizes! </Typography> </Grid> <Grid item xs={12} md={6} sx={{ display: { xs: "none", md: "inline-block" }, }} > {authenticated ? <Menu invert={false} /> : <LoginModule />} </Grid> </Grid> </Container> </Box> {isLoading ? ( <div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "50vh", }} > <Spin size="large" /> </div> ) : ( <> {categories != undefined && categories.length > 0 && ( <CategoryList categories={categories} onCategorySelect={onCategorySelect} /> )} {isCategoryLoading ? ( <div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "50vh", }} > <Spin size="large" /> </div> ) : ( competitions != undefined && competitions.length > 0 && ( <Box> <CompetitionList competitions={competitions} /> <Box sx={{ display: "flex", justifyContent: "center", mt: 5, }} > <Link href={`/categories?id=${selectedCategory}`} passHref> <ButtonCustom text={"Explore All"} onClick={() => exploreAll(selectedCategory)} /> </Link> </Box> </Box> ) )} </> )} <Box sx={{ mt: 10 }} /> <BackgroundPhotoFooter /> <Footer /> </> ); } </code>
"use client";
import BackgroundPhotoFooter from "@/elements/BackgroundPhoto";
import CategoryList from "@/elements/CategoryList";
import Footer from "@/elements/footer";
import { useEffect, useState } from "react";
import { Modal } from "antd/lib";
import { getCategories, getCompetitions } from "@/services/categories";
import { useTranslation } from "next-i18next";
import LoginModule from "@/elements/Login";
import { ICategory } from "@/models/Category";
import { Spin } from "antd";
import { ICompetition } from "@/models/Competition";
import CompetitionList from "@/elements/CompetitionList";
import { Box, Container, Grid, Typography } from "@mui/material";
import ButtonCustom from "@/elements/ButtonCustom";
import Link from "next/link";
import Menu from "@/elements/Menu";
import Header from "@/elements/header";
import Image from "next/image";
import { useKeycloak } from "@/context/KeycloakContext";

export default function Home() {
  const { t } = useTranslation("description");
  const [categories, setCategories] = useState<ICategory[]>([]);
  const [competitions, setCompetition] = useState<ICompetition[]>([]);
  const [isLoading, setLoading] = useState(true);
  const [isCategoryLoading, setCategoryLoading] = useState(true);
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [selectedCategory, setSelectedCategory] = useState(0);
  const { authenticated, loading: authLoading } = useKeycloak();

  const onCategorySelect = (id: number) => {
    setSelectedCategory(id);
    setCategoryLoading(true);
    getCompetitions()
      .then((data) => setCompetition(data))
      .catch((err) => console.error(err));
    setTimeout(() => {
      setCategoryLoading(false);
    }, 1000);
  };

  const handleOk = () => {
    setIsModalOpen(false);
  };

  const handleCancel = () => {
    setIsModalOpen(false);
  };

  useEffect(() => {
    if (isLoading) {
      try {
        getCategories()
          .then((data) => {
            setCategories(data);
            setSelectedCategory(data[0].id);
          })
          .catch((err) => console.error(err));

        getCompetitions()
          .then((data) => setCompetition(data))
          .catch((err) => console.error(err));
      } catch (err) {
        console.error("errore: " + err);
      }

      setTimeout(() => {
        setLoading(false);
        setCategoryLoading(false);
      }, 1000);
    }
  }, [isLoading]);

  const exploreAll = (categoryId: number) => {
    console.log("Explore category: " + categoryId);
  };

  if (authLoading) {
    return (
      <div
        style={{
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          height: "100vh",
        }}
      >
        <Spin size="large" />
      </div>
    );
  }

  return (
    <>
      <Header />
      <Modal
        title=""
        open={isModalOpen}
        onOk={handleOk}
        onCancel={handleCancel}
        footer={null}
        closable={false}
        okButtonProps={{ style: { display: "none" } }}
        cancelButtonProps={{ style: { display: "none" } }}
      >
        <div className="columns-2 ...">
          <div>
            <Image
              loading="lazy"
              quality={75}
              style={{ marginBottom: "30%" }}
              src="/dog.png"
              width={200}
              height={700}
              alt="dog"
            />
          </div>
          <div>
            <Image
              loading="lazy"
              quality={75}
              src="/ui.png"
              width={240}
              height={60}
              alt="photo image"
              style={{ marginLeft: "20px", marginTop: "20px" }}
            />
          </div>
        </div>
      </Modal>

      <Box
        style={{
          backgroundImage: `url(${"header.png"})`,
          width: "100%",
          height: "900px",
          backgroundPosition: "center",
          backgroundSize: "cover",
          backgroundRepeat: "no-repeat",
        }}
      >
        <Container maxWidth="xl">
          <Grid
            container
            spacing={6}
            sx={{
              pt: 10,
            }}
          >
            <Grid item xs={12} md={6}>
              <Box
                component="img"
                sx={{
                  mt: 10,
                  mb: 5,
                  height: "auto",
                  width: 300,
                }}
                alt="IShotIt"
                src="/logo.png"
              />
              <Typography variant="h1" sx={{ color: "white", mb: 4 }}>
                Show The World Your Best Photos.
              </Typography>
              <Typography variant="h2" sx={{ color: "white" }}>
                Recognized Awards and Big Prizes!
              </Typography>
            </Grid>

            <Grid
              item
              xs={12}
              md={6}
              sx={{
                display: { xs: "none", md: "inline-block" },
              }}
            >
              {authenticated ? <Menu invert={false} /> : <LoginModule />}
            </Grid>
          </Grid>
        </Container>
      </Box>
      {isLoading ? (
        <div
          style={{
            display: "flex",
            justifyContent: "center",
            alignItems: "center",
            height: "50vh",
          }}
        >
          <Spin size="large" />
        </div>
      ) : (
        <>
          {categories != undefined && categories.length > 0 && (
            <CategoryList
              categories={categories}
              onCategorySelect={onCategorySelect}
            />
          )}
          {isCategoryLoading ? (
            <div
              style={{
                display: "flex",
                justifyContent: "center",
                alignItems: "center",
                height: "50vh",
              }}
            >
              <Spin size="large" />
            </div>
          ) : (
            competitions != undefined &&
            competitions.length > 0 && (
              <Box>
                <CompetitionList competitions={competitions} />
                <Box
                  sx={{
                    display: "flex",
                    justifyContent: "center",
                    mt: 5,
                  }}
                >
                  <Link href={`/categories?id=${selectedCategory}`} passHref>
                    <ButtonCustom
                      text={"Explore All"}
                      onClick={() => exploreAll(selectedCategory)}
                    />
                  </Link>
                </Box>
              </Box>
            )
          )}
        </>
      )}
      <Box sx={{ mt: 10 }} />
      <BackgroundPhotoFooter />
      <Footer />
    </>
  );
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật