Skip to content

Commit

Permalink
update adapter-cloudflare docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Feb 2, 2022
1 parent d5e7d58 commit 52b31ee
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packages/adapter-cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,25 @@ When configuring your project settings, you must use the following settings:

The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object, containing KV namespaces etc, is passed to SvelteKit via the `platform` property, meaning you can access it in hooks and endpoints:

```ts
interface Locals {}
```diff
// src/app.d.ts
declare namespace App {
interface Locals {}

interface Platform {
env: {
COUNTER: DurableObjectNamespace;
};
+ interface Platform {
+ env: {
+ COUNTER: DurableObjectNamespace;
+ };
+ }

interface Session {}

interface Stuff {}
}
```

export async function post<Locals, Platform>({ request, platform }) {
```js
export async function post({ request, platform }) {
const counter = platform.env.COUNTER.idFromName('A');
}
```
Expand Down

0 comments on commit 52b31ee

Please sign in to comment.