Injecting Environment Variables into a Worker


I am currently developing a slackbot using cloudflare workers with webpack and serverless. What is the best practice for injecting env variables into the worker?



You can use KV (key/value) for that.


What’s the workflow. is it

Inject env variables into KV store and then deploy the worker?

Is it possible to use serverless for that or do we need to do it out of process.


You keep any setting you need in KV and deploy your worker. Your worker can access KV. It is recommended to use KV for reading although your worker can write, writes take a while to get synced across network and you cannot count on that for atomic operations.


thanks for the timely response

1 Like