Skip to content

Commit e0dd1b1

Browse files
fix: Adds note on setting up hyperdrive locally (#20622)
* fix: Adds note on setting up hyperdrive locally * Apply suggestions from code review Removing linebreaks. --------- Co-authored-by: Jun Lee <[email protected]>
1 parent ce000ab commit e0dd1b1

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/content/docs/hyperdrive/get-started.mdx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,14 @@ If successful, the command will output your new Hyperdrive configuration:
129129

130130
```json
131131
{
132-
"id": "<example id: 57b7076f58be42419276f058a8968187>",
133-
"name": "YOUR_CONFIG_NAME",
134-
"origin": {
135-
"host": "YOUR_DATABASE_HOST",
136-
"port": 5432,
137-
"database": "DATABASE",
138-
"user": "DATABASE_USER"
139-
},
140-
"caching": {
141-
"disabled": false
142-
}
132+
"hyperdrive": [
133+
{
134+
"binding": "HYPERDRIVE",
135+
"id": "<example id: 57b7076f58be42419276f058a8968187>"
136+
}
137+
]
143138
}
139+
144140
```
145141

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

152148
:::
153149

150+
154151
## 4. Bind your Worker to Hyperdrive
155152

156153
<Render file="create-hyperdrive-binding" product="hyperdrive" />

src/content/partials/hyperdrive/create-hyperdrive-binding.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,24 @@ Specifically:
2424
- 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`.
2525
- 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.
2626
- Your binding is available in your Worker at `env.<BINDING_NAME>`.
27+
28+
29+
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:
30+
31+
32+
<WranglerConfig>
33+
34+
```toml
35+
[[hyperdrive]]
36+
binding = "HYPERDRIVE"
37+
id = "<YOUR_DATABASE_ID>" # the ID associated with the Hyperdrive you just created
38+
localConnectionString = "<LOCAL_DATABASE_CONNECTION_URI>"
39+
```
40+
41+
</WranglerConfig>
42+
43+
:::note
44+
45+
Learn more about setting up [Hyperdrive for local development](/hyperdrive/configuration/local-development/).
46+
47+
:::

0 commit comments

Comments
 (0)