---
title: Control which routes invoke your Worker script for Single Page Applications
description: New configuration options for specifying which routes invoke your Worker script.
image: https://developers.cloudflare.com/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://developers.cloudflare.com/changelog/rss/index.xml) [ View RSS feeds ](https://developers.cloudflare.com/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://developers.cloudflare.com/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://developers.cloudflare.com/changelog/) 

## Control which routes invoke your Worker script for Single Page Applications

Jun 17, 2025 

[ Workers ](https://developers.cloudflare.com/workers/) 

For those building [Single Page Applications (SPAs) on Workers](https://developers.cloudflare.com/workers/static-assets/routing/single-page-application/#advanced-routing-control), you can now explicitly define which routes invoke your Worker script in Wrangler configuration. The [run\_worker\_first config option](https://developers.cloudflare.com/workers/static-assets/binding/#run%5Fworker%5Ffirst) has now been expanded to accept an array of route patterns, allowing you to more granularly specify when your Worker script runs.

**Configuration example:**

* [  wrangler.jsonc ](#tab-panel-2747)
* [  wrangler.toml ](#tab-panel-2748)

JSONC

```
{  "name": "my-spa-worker",  // Set this to today's date  "compatibility_date": "2026-07-01",  "main": "./src/index.ts",  "assets": {    "directory": "./dist/",    "not_found_handling": "single-page-application",    "binding": "ASSETS",    "run_worker_first": ["/api/*", "!/api/docs/*"]  }}
```

TOML

```
name = "my-spa-worker"# Set this to today's datecompatibility_date = "2026-07-01"main = "./src/index.ts"
[assets]directory = "./dist/"not_found_handling = "single-page-application"binding = "ASSETS"run_worker_first = [ "/api/*", "!/api/docs/*" ]
```

This new routing control was done in partnership with our community and customers who provided great feedback on [our public proposal ↗](https://github.com/cloudflare/workers-sdk/discussions/9143). Thank you to everyone who brought forward use-cases and feedback on the design!

#### Prerequisites

To use advanced routing control with `run_worker_first`, you'll need:

* [Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/) v4.20.0 and above
* [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/get-started/) v1.7.0 and above

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://developers.cloudflare.com/changelog/post/2025-06-17-advanced-routing/#page","headline":"Control which routes invoke your Worker script for Single Page Applications · Changelog","description":"New configuration options for specifying which routes invoke your Worker script.","url":"https://developers.cloudflare.com/changelog/post/2025-06-17-advanced-routing/","inLanguage":"en","image":"https://developers.cloudflare.com/changelog-preview.png","dateModified":"2025-06-17","datePublished":"2025-06-17","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
