Skip to main content
Version: 3.28.0

includeBytes

The includeBytes() function is used embed a file as a Uint8Array.

Note: Can only be used during build-time initialization, not when processing requests.

Syntax

includeBytes(path)

Parameters

  • path : string
    • The path to include, relative to the Fastly Compute application's top-level directory during build-time initialization.

Return value

Returns a Uint8Array

Examples

In this example we include the README.md file as a Uint8Array and use it for the body in the response we return to the client.

/// <reference types="@fastly/js-compute" />
import { includeBytes } from "fastly:experimental";
const readme = includeBytes('README.md');
async function app() {
return new Response(readme);
}
addEventListener("fetch", event => event.respondWith(app(event)));