<div> <h2>Program your traffic at the edge — fast, flexible, and free</h2> <a href="#program-your-traffic-at-the-edge-fast-flexible-and-free"> </a> </div> <p><a href="https://developers.cloudflare.com/rules/snippets/"><u>Cloudflare Snippets</u></a> are <b>now generally available (GA)</b> for all paid plans, giving you a fast, flexible way to control HTTP traffic using lightweight JavaScript “code rules” — at no extra cost.</p><p>Need to transform headers dynamically, fine-tune caching, rewrite URLs, retry failed requests, replace expired links, throttle suspicious traffic, or validate authentication tokens? Snippets provide a production-ready solution built for performance, security, and control.</p><p>With GA, we’re introducing a new <a href="https://developers.cloudflare.com/changelog/2025-01-29-snippets-code-editor/"><u>code editor</u></a> to streamline writing and testing logic. This summer, we’re also rolling out an integration with <a href="https://blog.cloudflare.com/secrets-store-beta/"><u>Secrets Store</u></a> — enabling you to bind and manage sensitive values like API keys directly in Snippets, securely and at scale.</p> <div> <h2>What are Snippets?</h2> <a href="#what-are-snippets"> </a> </div> <p>Snippets bring the power of JavaScript to <a href="https://developers.cloudflare.com/rules/"><u>Cloudflare Rules</u></a>, letting you write logic that runs before a request reaches your origin or after a response returns from upstream. They’re ideal when built-in rule actions aren’t quite enough. While Cloudflare Rules let you define traffic logic without code, Snippets extend that model with greater flexibility for advanced scenarios.</p><p>Think of Snippets as the ultra-fast <b>“code layer” </b>of <a href="https://developers.cloudflare.com/rules/"><u>Cloudflare Rules</u></a>: the <a href="https://developers.cloudflare.com/ruleset-engine/"><u>Ruleset Engine</u></a> evaluates your rules and invokes your code, which then runs on the <a href="https://developers.cloudflare.com/workers/runtime-apis/"><u>Workers runtime</u></a>.</p> <div> <h3>Key capabilities of Snippets:</h3> <a href="#key-capabilities-of-snippets"> </a> </div> <ul><li><p><b>Ultra-fast execution</b>: optimized for speed with the <a href="https://developers.cloudflare.com/ruleset-engine/"><u>Ruleset Engine</u></a> and <a href="https://developers.cloudflare.com/workers/runtime-apis/"><u>Workers runtime</u></a>.</p></li><li><p><b>Granular request matching</b>: trigger Snippets based on <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/fields/reference/http.request.full_uri/"><u>URI</u></a>, <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/fields/reference/http.user_agent/"><u>user-agent</u></a>, <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/fields/reference/http.request.cookies/"><u>cookies</u></a>, headers and more.</p></li><li><p><b>Sequential execution</b>: <a href="https://developers.cloudflare.com/rules/snippets/how-it-works/"><u>run</u></a> multiple Snippets on the same request, applying modifications step by step.</p></li><li><p>Native <a href="https://developers.cloudflare.com/rules/"><u>Cloudflare Rules</u></a> integration: Snippets <a href="https://developers.cloudflare.com/ruleset-engine/reference/phases-list/#request-phases"><u>inherit</u></a> request modifications from other Cloudflare products.</p></li><li><p>JavaScript and Web APIs support, plus essential <a href="https://developers.cloudflare.com/workers/runtime-apis/"><u>Workers runtime</u></a> features:</p><ul><li><p><a href="https://developers.cloudflare.com/workers/runtime-apis/fetch/"><u>fetch API</u></a></p></li><li><p><a href="https://developers.cloudflare.com/workers/runtime-apis/cache/"><u>cache API</u></a></p></li><li><p><a href="https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties"><u>request.cf object</u></a></p></li><li><p><a href="https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/"><u>HTMLRewriter</u></a></p></li></ul></li><li><p>Automated deployment and versioning via <a href="https://developers.cloudflare.com/rules/snippets/create-terraform/"><u>Terraform</u></a>.</p></li></ul><p>Best of all? Snippets are <a href="https://developers.cloudflare.com/rules/snippets/#availability"><u>included</u></a> at no extra cost for Pro, Business, and Enterprise plans — with <b>no usage-based fees</b>.</p> <div> <h2>The journey to GA: How Snippets became production-grade</h2> <a href="#the-journey-to-ga-how-snippets-became-production-grade"> </a> </div> <p>Cloudflare Snippets started as a bold idea: bring the power of JavaScript-based logic to Cloudflare Rules, without the complexity of a full-stack developer platform.</p><p>Over the past two years, Snippets have evolved into a production-ready “code rules” solution, shaping the future of HTTP traffic control.</p><p><b>2022:</b> Cloudflare Snippets were <a href="https://blog.cloudflare.com/snippets-announcement/"><u>announced</u></a> during Developer Week as a solution for users needing flexible HTTP traffic modifications without a full Worker.</p><p><b>2023:</b> <b>Alpha launch </b>— hundreds of users tested Snippets for high-performance traffic logic.</p><p><b>2024:</b> <b>7x traffic growth</b>, processing 17,000 requests per second. Terraform support and production-grade backend were released.</p><p><b>2025:</b> <b>General Availability </b>— Snippets introduces a <a href="https://developers.cloudflare.com/changelog/2025-01-29-snippets-code-editor/"><u>new code editor</u></a>, <a href="https://developers.cloudflare.com/changelog/2025-02-12-rules-upgraded-limits/"><u>increased limits</u></a> alongside other Cloudflare Rules products, integration with <a href="https://developers.cloudflare.com/fundamentals/trace-request/#_top"><u>Trace</u></a>, and a production-grade experience built for scale, handling <b>over 2 million requests per second</b> at peak. Integration with the Secrets Store is rolling out this summer.</p> <figure> <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/1fZv7cpSGntSQadS761Zkv/31707075a85d393f4883b190599581f7/1.png" /> </figure> <div> <h2>New: Snippets + Secrets Store</h2> <a href="#new-snippets-secrets-store"> </a> </div> <p><a href="https://developers.cloudflare.com/fundamentals/trace-request/#_top"><u>Cloudflare Trace</u></a> now shows exactly which Snippets were triggered on a request. This makes it easier to debug traffic behavior, verify logic execution, and understand how your Snippets interact with other products in the request pipeline.</p><p>Whether you’re fine-tuning header logic or troubleshooting a routing issue, Trace gives you real-time insight into how your edge logic behaves in production.</p> <div> <h2>Coming soon: Snippets + Secrets Store</h2> <a href="#coming-soon-snippets-secrets-store"> </a> </div> <p>In the third quarter, you’ll be able to securely access API keys, authentication tokens, and other sensitive values from <a href="https://blog.cloudflare.com/secrets-store-beta/"><u>Secrets Store</u></a> directly in your Snippets. No more plaintext secrets in your code, no more workarounds.</p><div> Once rolled out, secrets can be configured for Snippets via the dashboard or API under the new “Settings” button.
...