Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(guides/envvars): clarify docs for local/production env variables #3368

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

dgurns
Copy link
Contributor

@dgurns dgurns commented Jun 2, 2022

When I recently spun up a project using the @remix-run/cloudflare-pages adapter, it was not clear how to set up and use env variables, both locally and when deployed to Cloudflare Pages.

Thankfully @jemjam figured it out in this issue comment

This updates the Environment Variables docs with that information. This should hopefully save people a lot of pain when initially setting up a new project with the Cloudflare Pages adapter.

@dgurns dgurns changed the title Add information to docs about using env variables with Cloudflare Pages adapter docs(env-vars): Add information about using env variables with Cloudflare Pages adapter Jun 2, 2022
@dgurns dgurns changed the title docs(env-vars): Add information about using env variables with Cloudflare Pages adapter docs(envvars): Add information about using env variables with Cloudflare Pages adapter Jun 2, 2022
@machour machour added the docs label Jun 2, 2022
@machour
Copy link
Collaborator

machour commented Jun 2, 2022

@dgurns Thank you for opening this PR !

This seems a little too specific to me, and perhaps should be added in a new, CF specific, section. @kentcdodds WDYT?

docs/guides/envvars.md Outdated Show resolved Hide resolved
docs/guides/envvars.md Outdated Show resolved Hide resolved

{
"scripts": {
"dev:wrangler": "cross-env NODE_ENV=development wrangler pages dev ./public --binding $(cat .env)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, I didn't even think to cat the env file, I've been binding these values individually (like a fool)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gotta give a h/t to @theeomm on that one! #3186 (comment)

@jemjam
Copy link

jemjam commented Jun 2, 2022

Just threw some minor thoughts up, take or leave my opinions if you choose to use any of this. ❤️

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jun 2, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@dgurns
Copy link
Contributor Author

dgurns commented Jun 2, 2022

Thanks for the great feedback folks. I updated the doc to be better organized, dividing "Server Environment Variables" into "Local Development" and "Production" sections.

@dgurns dgurns changed the title docs(envvars): Add information about using env variables with Cloudflare Pages adapter docs(envvars): Clarify docs for local/production env variables, including with Cloudflare Pages adapter Jun 2, 2022
@MichaelDeBoey MichaelDeBoey changed the title docs(envvars): Clarify docs for local/production env variables, including with Cloudflare Pages adapter docs(guides/envvars): clarify docs for local/production env variables Jun 2, 2022
@MichaelDeBoey
Copy link
Member

@theeomm already updated the cloudflare-pages template in #3186, so I don't think these doc changes are necessary anymore once his PR is merged? 🤔

@dgurns
Copy link
Contributor Author

dgurns commented Jun 3, 2022

@theeomm already updated the cloudflare-pages template in #3186, so I don't think these doc changes are necessary anymore once his PR is merged? 🤔

That PR looks great and will help, but I think this one is important as well. If you're a new user with a Cloudflare Pages project:

  • It's not clear that you can use a .env file - usually Cloudflare projects use a wrangler.toml locally for env variables, if I understand correctly.
  • Once you have the env variables loaded in, it's not clear how to access them. I initially reached for process.env by default, and then top-level global variables like Cloudflare Workers, before realizing by trial and error that they were on context.

@theeomm
Copy link

theeomm commented Jun 3, 2022

@theeomm already updated the cloudflare-pages template in #3186, so I don't think these doc changes are necessary anymore once his PR is merged? 🤔

That PR looks great and will help, but I think this one is important as well. If you're a new user with a Cloudflare Pages project:

  • It's not clear that you can use a .env file - usually Cloudflare projects use a wrangler.toml locally for env variables, if I understand correctly.
  • Once you have the env variables loaded in, it's not clear how to access them. I initially reached for process.env by default, and then top-level global variables like Cloudflare Workers, before realizing by trial and error that they were on context.

I think it is necessary for this PR to be merged too as it really documents how to handle environment variables with CF, which I should have probably done in my PR in the first place.

docs/guides/envvars.md Show resolved Hide resolved
@kentcdodds kentcdodds merged commit 70902b5 into remix-run:main Jun 7, 2022
@kentcdodds
Copy link
Member

Thanks everyone!

@dgurns
Copy link
Contributor Author

dgurns commented Jun 7, 2022

Cool! Gotta say I am super impressed with the Remix community so far. Thank you all for jumping in with feedback so quickly on the PR, and seeing it merged in a few days. Amazing stuff! Excited to keep digging in to Remix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants