2

I am setting up a Next.JS site and would like to retrieve the site url. For example, if I have a local install, then the site url would be localhost:3000. If I deploy the site, then it would be www.my-domainame.com.

I thought I could do this via the next.js useRouter hook. But upon closer look it does not seem to return that information. It has information about the path and query, but not about the site url.

As such, I am wondering -- how can I do this in Next.JS?

Thanks.

Moshe
  • 6,011
  • 16
  • 60
  • 112
  • 1
    Does this answer your question: [How to get page URL or hostname in NextJs Project?](https://stackoverflow.com/questions/65199051/how-to-get-page-url-or-hostname-in-nextjs-project)? – juliomalves Jul 21 '21 at 22:50
  • https://www.npmjs.com/package/next-absolute-url – brc-dd Jul 22 '21 at 03:22

0 Answers0