Loading video...

Video Failed to Load

Go Home

You can remove all console calls from prod in Next.js

146,413 views • 1 year ago •via X (Twitter)

10 Comments

Alex Sidorenko's profile picture
Alex Sidorenko1 year ago

Note that it removes all console calls both from the client and the server in prod. You can exclude specific methods if you want to keep them:

Ninio's profile picture
Ninio1 year ago

One level higher is introducing a `INTERNAL_ENV` environment variable, which is `dev`, `stage` or `prod`. And then you can have the console.log's showing up in staging, but not on production 🚀

Prakhar Shukla's profile picture
Prakhar Shukla1 year ago

shouldn’t your linter handle this? Have a linting job that removes console logs.

Malvin 🇬🇭's profile picture
Malvin 🇬🇭1 year ago

Yes! I’ve been doing it all the way from v11. Next is super!

Prasenjit's profile picture
Prasenjit1 year ago

That's super useful. Thank you for the share, Alex

pankaj's profile picture
pankaj1 year ago

but we test on prod

Adil - medusa/acc - oss/acc's profile picture
Adil - medusa/acc - oss/acc1 year ago

simple and efficient 🙌

⅃ ℺ ℇ 💀's profile picture
⅃ ℺ ℇ 💀1 year ago

but then how will we debug in prod?

Frank Flitton's profile picture
Frank Flitton1 year ago

Woah that’s cool. Does that include stdout on the server too?

Jordan Hall's profile picture
Jordan Hall1 year ago

This is kinda bad for any logging npm packages that override console logging

Related Videos