In Next 13, I have a list of products with categories. I want to put these categories into constants so I can check if a product belongs to one category or another. For example: if (product.id === CONSTANTS.DRINKS) { //do something with the product if it is from the drinks category } These constants would be populated upon a request to an external API. They must be filled in throughout the code and will be used in both common javascript files and React components. Is there a way to do this in the next 13? Considering that there are files that are rendered on the server and other files that use RTK that will be rendered on the client. Is there another approach to distributing these constants throughout the code? I tried to make a request to the API to fill in the constants, but as there are files that are rendered on the server and others on the client, it didn't work as I expected. They must only be filled once and all code will be able to see this value filled.
Thanks for the clear explanation, you've just earned my subscription to your channel. Kudos! Edit: One more thing, is there a possibility that I can access env variables without "NEXT_PUBLIC_XXXX" in the browser?
Thank you Dark! And unfortunately, it does not seem so on the browser. According to their docs here nextjs.org/docs/basic-features/environment-variables
Insanely underrated. Keep it up man
In Next 13, I have a list of products with categories. I want to put these categories into constants so I can check if a product belongs to one category or another. For example:
if (product.id === CONSTANTS.DRINKS) { //do something with the product if it is from the drinks category }
These constants would be populated upon a request to an external API. They must be filled in throughout the code and will be used in both common javascript files and React components. Is there a way to do this in the next 13? Considering that there are files that are rendered on the server and other files that use RTK that will be rendered on the client. Is there another approach to distributing these constants throughout the code?
I tried to make a request to the API to fill in the constants, but as there are files that are rendered on the server and others on the client, it didn't work as I expected. They must only be filled once and all code will be able to see this value filled.
Very well explained. Keep it up. Subscribed
env tesing how
Thank you!!!
Welcome!
Thanks for the clear explanation, you've just earned my subscription to your channel. Kudos!
Edit: One more thing, is there a possibility that I can access env variables without "NEXT_PUBLIC_XXXX" in the browser?
Thank you Dark! And unfortunately, it does not seem so on the browser. According to their docs here nextjs.org/docs/basic-features/environment-variables
This sucks
subscribed