Cloudflare Enablement
Pages
Testing
Edit this page on GitHub
Set theme to dark (⇧+D)

TypeScript

Pages Functions supports TypeScript. Author any files in your /functions directory with a .ts extension instead of a .js extension to start using TypeScript.

To add the runtime types to your project, run:

Then configure the runtime types by creating a functions/tsconfig.json file:

If you already have a tsconfig.json at the root of your project, you may wish to explicitly exclude the /functions directory to avoid conflicts. To exclude the /functions directory:

Pages Functions can be typed using the PagesFunction type. This type accepts an Env parameter. To use the env parameter: