Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up the home page on Next.js

Does anybody know how to define any specific page in Next.js as the root (the home page)?

I have been looking online and was not able to find any concrete solutions. This is suppose to be a very common use case.

There is this other post, Using Next.js next-routes, how to define a home route for the base web page?, but it recommends creating a server for it.

Is there any "NextJs" way of setting up a Home Page?

Thanks in advance!

like image 232
drjorgepolanco Avatar asked Nov 16 '25 03:11

drjorgepolanco


1 Answers

Here is the solution offered by nextjs.

Create or edit the file next.config.js in the root directory:

module.exports = {
  async redirects() {
    return [
      {
        source: '/',
        destination: '/about',
        permanent: true,
      },
    ]
  },
}

Source: https://nextjs.org/docs/api-reference/next.config.js/redirects

like image 135
Chris Routy Avatar answered Nov 18 '25 20:11

Chris Routy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!