Injecting Environment Variables into a Worker

#1

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?

cheers

#2

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

#3

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.

#4

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.

#5

thanks for the timely response

1 Like