Can I use .dotenv library as HTML script imports only without npm or node.js?

4.8k Views Asked by At

Is there a way to use dotenv library as an import (e.g from CDN) only in a HTML script tag or .js file? I mean without node or npm require or imports.. Otherwise I would have to use something like webpack and I just want to test it quickly on a HTML page...

1

There are 1 best solutions below

5
On BEST ANSWER

Short answer: No.

dotenv is a backend tool for getting variables set in a .env file. If you are using .env files for public use, that is misusing what the point of environment variables are for. Maybe try just using a filename.json or fileame.yml file for public consumption, but .env files are only used for secret things, like API keys, database passwords, etc.