# Workers: bundling prerequisite, env key, handler-scoped client
Prerequisites from the guide: a Resend API key, a verified domain, and a
Cloudflare worker with a bundling setup (the guide recommends bootstrapping
with npm create cloudflare).
```ts
import { Resend } from 'resend';
export default {
async fetch(request: Request, env: Env): Promise[Response] {
const resend = new Resend(env.RESEND_API_KEY);
const { data, error } = await resend.emails.send({
from: '[SENDER]',
to: ['[RECIPIENT]'],
subject: 'Hello World',
html: '<strong>It works!</strong>',
});
if (error) {
return Response.json({ error }, { status: 400 });
}
return Response.json({ id: data.id });
},
};
```
## Checklist
- The guide writes `new Resend('re_xxxxxxxxx')`. That is a placeholder. Bind the
real key as a worker secret and read it from `env`. A literal in source ends
up in the bundle and in version control.
- Construct the client inside `fetch` where `env` is available. Module scope
has no access to the worker environment.
- Keep the bundling setup the guide asks for. The SDK is an npm package; a
worker without a bundler cannot import it.