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

Add way to add env variables during runtime #5

Closed
ghost opened this issue Apr 21, 2023 · 4 comments · May be fixed by #25
Closed

Add way to add env variables during runtime #5

ghost opened this issue Apr 21, 2023 · 4 comments · May be fixed by #25

Comments

@ghost
Copy link

ghost commented Apr 21, 2023

Now vite doesn't support adding env variables during runtime, but without that feature we cannot add env variables while creating docker container.

Related issues:
sveltejs/kit#3004

@Skulrag
Copy link

Skulrag commented Jun 5, 2023

Hi,

A solution for me was to follow this tutorial that explain how to use dynamic variable via a built-in module :

https://joyofcode.xyz/sveltekit-environment-variables

I added this import on my server files :
import { env } from '$env/dynamic/private'

After that I can use my env var like this :

console.log(env.MY_VAR)

My problem was not been able to use docker compose env var ! It solved it.

@lucasmgsilva
Copy link

Hi,

A solution for me was to follow this tutorial that explain how to use dynamic variable via a built-in module :

https://joyofcode.xyz/sveltekit-environment-variables

I added this import on my server files : import { env } from '$env/dynamic/private'

After that I can use my env var like this :

console.log(env.MY_VAR)

My problem was not been able to use docker compose env var ! It solved it.

Any alternatives to React with Vite?

@ghost
Copy link
Author

ghost commented Oct 10, 2023

Hi,
A solution for me was to follow this tutorial that explain how to use dynamic variable via a built-in module :
https://joyofcode.xyz/sveltekit-environment-variables
I added this import on my server files : import { env } from '$env/dynamic/private'
After that I can use my env var like this :
console.log(env.MY_VAR)
My problem was not been able to use docker compose env var ! It solved it.

Any alternatives to React with Vite?

In this project i used import-meta-env. great tool! you can see project example in this repository

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants