Next js Tutorial 2021 | Part 13 - Environment Variables

Поделиться
HTML-код
  • Опубликовано: 16 окт 2024

Комментарии • 10

  • @freemanjiang
    @freemanjiang 2 года назад +1

    Insanely underrated. Keep it up man

  • @DhiegoSpider
    @DhiegoSpider 5 месяцев назад

    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.

  • @tamuahmed5303
    @tamuahmed5303 3 года назад

    Very well explained. Keep it up. Subscribed

  • @huyohuu6340
    @huyohuu6340 3 года назад +1

    env tesing how

  • @miguelalzate4850
    @miguelalzate4850 3 года назад

    Thank you!!!

  • @brindch8372
    @brindch8372 3 года назад

    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?

    • @CodeDunks
      @CodeDunks  3 года назад

      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

    • @panicbox4609
      @panicbox4609 2 года назад

      This sucks

  • @motivationandjs9073
    @motivationandjs9073 3 года назад

    subscribed