Next.js Tutorial - 64 - Environment Variables

Next.js Tutorial - 64 - Environment Variables

Codevolution

3 года назад

54,871 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@EJK2099
@EJK2099 - 12.08.2021 16:33

First

Ответить
@jatinhemnani1029
@jatinhemnani1029 - 17.08.2021 17:23

If im doing Client Side Rendering, how can I prevent exposing my URL in network tab while making requests

Ответить
@nerosonic
@nerosonic - 17.09.2021 08:20

lol he says the last words so weirdly

Ответить
@domenicocucinotta2720
@domenicocucinotta2720 - 02.10.2021 17:28

I have follows tons of tutorials and lots of reading. As always, you answered all my questions! Thanks a lot!

Ответить
@polorplays6340
@polorplays6340 - 15.11.2021 19:23

thanks so much!!

Ответить
@ifelipesilva
@ifelipesilva - 21.11.2021 03:03

oh man thank you,

hello from brazil xD

Ответить
@notyournormaldev1419
@notyournormaldev1419 - 23.11.2021 00:10

Why can't we do object destructuring with process.env

Ответить
@RubberDuckCoding
@RubberDuckCoding - 31.12.2021 11:40

VERY NICE!

Ответить
@alihamdan9600
@alihamdan9600 - 26.01.2022 13:48

THANKS

Ответить
@devanwoodruff7289
@devanwoodruff7289 - 22.02.2022 20:58

Thank you good sir!

Ответить
@goranilic4412
@goranilic4412 - 29.03.2022 16:44

No words about ENV variables for production.

Ответить
@thisisnotfinancialadvice3803
@thisisnotfinancialadvice3803 - 13.05.2022 10:35

thanks

Ответить
@itstatanka
@itstatanka - 19.05.2022 23:33

.env.local does not work for me

Ответить
@TheDevFounder
@TheDevFounder - 13.06.2022 07:53

This is so incomplete. Why nothing about different environment files. That's the whole point.

Ответить
@robinsongonzalez5352
@robinsongonzalez5352 - 30.09.2022 22:10

I LOVE U INDIAN MAN

Ответить
@patrickconrad396
@patrickconrad396 - 08.11.2022 18:17

Super annoyed. I've followed the docs and multiple videos and my public env variables is still returning undefined...

Ответить
@jesusgomezbranagonzalez4892
@jesusgomezbranagonzalez4892 - 02.01.2023 02:39

This video is outdated. Here is what you need to do
1. Create an .env file (just .env no need for .local)
2. Install dotenv module (npm install dotenv)
3. Open next.config.js
4. Copy and paste the following code
/** @type {import('next').NextConfig} */
const fs = require('fs');


const dotenv = require('dotenv');

const env = dotenv.parse(fs.readFileSync('.env'));

const nextConfig = {
reactStrictMode: true,
env: env
}

module.exports = nextConfig

Ответить
@j3z741
@j3z741 - 10.02.2023 23:06

I love you too! 🤪

Ответить
@daniel_iliesh
@daniel_iliesh - 24.04.2023 23:15

Allowe you too man

Ответить
@mikemalone4867
@mikemalone4867 - 19.05.2023 04:26

To anyone struggling out there trying to get these .env variables to work and you are using as of this time version 13.*.*, what is shown here does not work. You WILL need to to the following:

Add .env.* to your .gitignore file.
Create the .env.local file
Add your variable prefixed with NEXT_PUBLIC_

If you do not do this, you cannot see these variables locally via the client. All variables without the NEXT_PUBLIC_ prefix will be available server side ONLY. They reference this in the docs from Next.js but they don't explain it very well. I struggled with this for about 30 minutes before I figured it out.

Ответить
@thinBillyBoy
@thinBillyBoy - 12.09.2023 08:47

Hi! I need help with something :( Everyone at work can put their .env file under utils map but mine doesn't load unless I put it in the root dir
Do you have any idea why? :o Ty!

Ответить
@Versole
@Versole - 14.01.2024 01:30

I wasted 2 days figuring out exactly why isn't my environment variables aren't showing and now realize that all I have to do was to include NEXT_PUBLIC next to it. Thank you

Ответить
@instagramaccount6748
@instagramaccount6748 - 07.03.2024 08:35

Showing undefined
I am using nextjs 13.5

Ответить
@maxboucher
@maxboucher - 04.05.2024 15:11

Great tutorial. Simple, clear, and concise. Thank you!

Ответить