Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/content/docs/hyperdrive/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,14 @@ If successful, the command will output your new Hyperdrive configuration:

```json
{
"id": "<example id: 57b7076f58be42419276f058a8968187>",
"name": "YOUR_CONFIG_NAME",
"origin": {
"host": "YOUR_DATABASE_HOST",
"port": 5432,
"database": "DATABASE",
"user": "DATABASE_USER"
},
"caching": {
"disabled": false
}
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<example id: 57b7076f58be42419276f058a8968187>"
}
]
}

```

Copy the `id` field: you will use this in the next step to make Hyperdrive accessible from your Worker script.
Expand All @@ -151,6 +147,7 @@ Hyperdrive will attempt to connect to your database with the provided credential

:::


## 4. Bind your Worker to Hyperdrive

<Render file="create-hyperdrive-binding" product="hyperdrive" />
Expand Down
21 changes: 21 additions & 0 deletions src/content/partials/hyperdrive/create-hyperdrive-binding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,24 @@ Specifically:
- The value (string) you set for the `name` (binding name) will be used to reference this database in your Worker. In this tutorial, name your binding `HYPERDRIVE`.
- The binding must be [a valid JavaScript variable name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variables). For example, `binding = "hyperdrive"` or `binding = "productionDB"` would both be valid names for the binding.
- Your binding is available in your Worker at `env.<BINDING_NAME>`.


If you wish to use a local database during development, you can add a `localConnectionString` to your Hyperdrive configuration with the connection string of your database:


<WranglerConfig>

```toml
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "<YOUR_DATABASE_ID>" # the ID associated with the Hyperdrive you just created
localConnectionString = "<LOCAL_DATABASE_CONNECTION_URI>"
```

</WranglerConfig>

:::note

Learn more about setting up [Hyperdrive for local development](/hyperdrive/configuration/local-development/).

:::
Loading