You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, make sure to have [Fastly's CLI](https://developer.fastly.com/learning/tools/cli/) installed:
13
+
This site is the full SDK reference for [@fastly/js-compute](https://www.npmjs.com/package/@fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
14
14
15
-
The Fastly CLI is available for multiple operating systems.
15
+
If you haven't used Compute@Edge before, start by [setting up your first Compute@Edge program](https://developer.fastly.com/learning/compute/) over on **developer.fastly.com** so that you have a working development environment.
16
16
17
-
-**MacOS**: Install from Homebrew:
17
+
To learn more about the fundamentals of using JavaScript with Compute@Edge, see our [using JavaScript](https://developer.fastly.com/learning/compute/javascript/) guide.
18
18
19
-
```
20
-
brew install fastly/tap/fastly
21
-
```
19
+
## Understanding the JavaScript SDK
22
20
23
-
-**Windows**: [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the prebuilt binary for your architecture.
24
-
-**Linux**: Packages are available for many distributions, along with prebuilt binaries. [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the package for your distribution.
21
+
Incoming HTTP requests to domains that are attached to your Fastly service will start an instance of your application and invoke a `fetch` event, which can be bound using the `addEventListener` function:
Fastly specific features are available as named imports from `fastly:` prefixed modules, all of which are documented in this site. For example, the [env](https://js-compute-reference-docs.edgecompute.app/docs/fastly:env/env) function provides access to [environment variables](https://developer.fastly.com/reference/compute/ecp-env/) and can be imported into your application like this:
35
36
36
-
```
37
-
npm install
37
+
```js
38
+
import { env } from"fastly:env"
38
39
```
39
40
40
-
## Try it out locally
41
+
JavaScript code compiled for Compute@Edge has access to a global environment with most of the globals you would expect in an ECMAScript runtime, like [`Date`](https://js-compute-reference-docs.edgecompute.app/docs/globals/Date/) and [`console`](https://js-compute-reference-docs.edgecompute.app/docs/globals/console/log).
41
42
43
+
## Trying things out
42
44
43
-
```shell
44
-
fastly compute serve --watch
45
-
```
46
-
47
-
Your application should now be running on [http://localhost:7676](http://localhost:7676)
45
+
[Fastly fiddle](https://fiddle.fastly.dev) is an online web-based playground where you can run Fastly code. You'll see fiddles included in many pages of our [developer hub](https://developer.fastly.com) and this SDK reference. These interactive examples can be executed right on the page by clicking the **RUN** tab:
0 commit comments