Examples (11)
Last updated May 20, 2026 Explore the following examples for Workers.
Stream large JSON Parse and transform large JSON request and response bodies using streaming.
HTTP Basic Authentication Shows how to restrict access using the HTTP Basic schema.
Fetch HTML Send a request to a remote server, read HTML from the response, and serve that HTML.
Return small HTML page Deliver an HTML page from an HTML string directly inside the Worker script.
Return JSON Return JSON directly from a Worker script, useful for building APIs and middleware.
Sign requests Verify a signed request using the HMAC and SHA-256 algorithms or return a 403.
Stream OpenAI API Responses Use the OpenAI v4 SDK to stream responses from OpenAI.
103 Early Hints Allow a client to request static assets while waiting for the HTML response.
Cache Tags using Workers Send Additional Cache Tags using Workers
Aggregate requests Send two GET request to two urls and aggregates the responses into one response.
Block on TLS Inspects the incoming request's TLS version and blocks if under TLSv1.2.
Bulk redirects Redirect requests to certain URLs based on a mapped object to the request's URL.
Cache POST requests Cache POST requests using the Cache API.
Fetch JSON Send a GET request and read in JSON from the response. Use to fetch external data.
Geolocation: Custom Styling Personalize website styling based on localized user time.
Geolocation: Hello World Get all geolocation data fields and display them in HTML.
Post JSON Send a POST request with JSON data. Use to share data with external servers.
Redirect Redirect requests from one URL to another or from one set of URLs to another set.
Multiple Cron Triggers Set multiple Cron Triggers on three different schedules.
Setting Cron Triggers Set a Cron Trigger for your Worker.
Geolocation: Weather application Fetch weather data from an API using the user's geolocation data.
Bulk origin override Resolve requests to your domain to a set of proxy third-party origin URLs.
Using the Cache API Use the Cache API to store responses in Cloudflare's cache.
CORS header proxy Add the necessary CORS headers to a third party API response.
Country code redirect Redirect a response based on the country code in the header of a visitor.
Debugging logs Send debugging information in an errored response to a logging service.
Modify response Fetch and modify response properties which are immutable by creating a copy first.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers/examples/#page","headline":"Examples","description":"Browse code examples and starter templates for Cloudflare Workers.","url":"https://developers.cloudflare.com/workers/examples/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/examples/og.png?v=e7b4e199277c303d","dateModified":"2026-05-20","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Allow a client to request static assets while waiting for the HTML response. title: 103 Early Hints image: https://developers.cloudflare.com/workers/examples/103-early-hints/og.png?v=f9807f4df12fc584
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.
Docs