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(oauth-providers): use process.env instead of Bun.env as default #612

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

euxn23
Copy link

@euxn23 euxn23 commented Jul 3, 2024

Now Bun is not standard, so I think README should use process.env instead of Bun.env, so I replaced Bun.env to process.env in this PR.
But there is a difference between Bun.env and process.env, I also added note about Bun.

Copy link

changeset-bot bot commented Jul 3, 2024

⚠️ No Changeset found

Latest commit: fba3d9e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@yusukebe
Copy link
Member

yusukebe commented Jul 3, 2024

Hi @euxn23

Regarding env variables, we can use the adapter helper:

https://hono.dev/docs/helpers/adapter#env

import { env } from 'hono/adapter'

app.get('/env', (c) => {
  // NAME is process.env.NAME on Node.js or Bun
  // NAME is the value written in `wrangler.toml` on Cloudflare
  const { NAME } = env<{ NAME: string }>(c)
  return c.text(NAME)
})

I think using this would be better than using other runtime-specific variables.

@nick-cjyx9
Copy link

Hi @euxn23

Regarding env variables, we can use the adapter helper:

https://hono.dev/docs/helpers/adapter#env

import { env } from 'hono/adapter'

app.get('/env', (c) => {
  // NAME is process.env.NAME on Node.js or Bun
  // NAME is the value written in `wrangler.toml` on Cloudflare
  const { NAME } = env<{ NAME: string }>(c)
  return c.text(NAME)
})

I think using this would be better than using other runtime-specific variables.

But env() requires a c: Context param, which we cannot get out of a handler.

@nick-cjyx9
Copy link

the same question in #398

@yusukebe
Copy link
Member

yusukebe commented Aug 2, 2024

Hi @nick-cjyx9

But env() requires a c: Context param, which we cannot get out of a handler.

You are right. If you want to use environment variables out of a handler, you have to use Bun.env, process.env, or another runtime-dependent variable. In this case, it will be used in the middleware handler, so we have to use env().

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

Successfully merging this pull request may close these issues.

3 participants