Uploading NextJS to Vercel
Answered
Sjödda posted this in #help-forum
SjöddaOP
Hey,
I uploading my NextJS project to Vercel, but I keep getting the error:
However, I can run
Only when I upload the project, and Vercel runs
I don't mention
Here's the github repo:
https://github.com/ilittlebig/eliasmattor-development
Thank you!
I uploading my NextJS project to Vercel, but I keep getting the error:
navigator is not defined.However, I can run
npm run build perfectly fine on my own computer.Only when I upload the project, and Vercel runs
npm run build, it gives me that error.I don't mention
navigator anywhere in the codebase, I don't think.Here's the github repo:
https://github.com/ilittlebig/eliasmattor-development
Thank you!
Answered by Ray
const currencyFormatter = (
amount: number,
currency: string,
locale: string = navigator.language
): string => {
if (typeof window === "undefined") return "";
return new Intl.NumberFormat(locale, {
style: "currency",
currency: currency,
}).format(amount);
};
export default currencyFormatter;6 Replies
SjöddaOP
oops, sorry, forgot to make it public
it's public now
@Sjödda Hey,
I uploading my NextJS project to Vercel, but I keep getting the error: `navigator is not defined`.
However, I can run `npm run build` perfectly fine on my own computer.
Only when I upload the project, and Vercel runs `npm run build`, it gives me that error.
I don't mention `navigator` anywhere in the codebase, I don't think.
Here's the github repo:
https://github.com/ilittlebig/eliasmattor-development
Thank you!
const currencyFormatter = (
amount: number,
currency: string,
locale: string = navigator.language
): string => {
if (typeof window === "undefined") return "";
return new Intl.NumberFormat(locale, {
style: "currency",
currency: currency,
}).format(amount);
};
export default currencyFormatter;Answer
Intl use navigator under the hoodSjöddaOP
oh wow, thank you very much!