Skip to content

Need instructions for existing workers #15343

@rampatra

Description

@rampatra

Existing documentation URL(s)

Doc link - https://developers.cloudflare.com/d1/get-started/

This page lists nicely the steps when creating a worker from scratch but what if someone already has a worker defined and set up and are adding the D1 database to it. What node dependency to add, etc. can be mentioned.

For example, I have a nextjs app set up already and I want to add D1 database to it. So, how shall I do that?

Currently, the below is giving me an error (D1Database not found):

export interface Env {
    // If you set another name in wrangler.toml as the value for 'binding',
    // replace "DB" with the variable name you defined.
    DB: D1Database;
}

I ran this too npm install @cloudflare/workers-types @cloudflare/d1 but no luck.

What changes are you suggesting?

It should contain steps to do for existing worker.

Additional information

No response

Metadata

Metadata

Labels

content:editRequest for content editsdocumentationDocumentation editsproduct:d1D1: https://developers.cloudflare.com/d1/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions