TypeScript example
The TypeScriptExample component is used 1189 times on 225 pages.
See all examples of pages that use TypeScriptExample
Used 1189 times.
Pages
- /agent-memory/get-started/ - Source
- /agents/communication-channels/chat/autonomous-responses/ - Source
- /agents/communication-channels/chat/chat-agents/ - Source
- /agents/communication-channels/chat/client-sdk/ - Source
- /agents/communication-channels/email/ - Source
- /agents/communication-channels/voice/ - Source
- /agents/communication-channels/webhooks/ - Source
- /agents/communication-channels/webhooks/push-notifications/ - Source
- /agents/concepts/agentic-patterns/human-in-the-loop/ - Source
- /agents/concepts/calling-llms/ - Source
- /agents/concepts/conversation-state-and-memory/ - Source
- /agents/concepts/workflows/ - Source
- /agents/examples/browser-agent/ - Source
- /agents/examples/chat-agent/ - Source
- /agents/examples/email-agent/ - Source
- /agents/examples/voice-agent/ - Source
- /agents/getting-started/add-to-existing-project/ - Source
- /agents/getting-started/quick-start/ - Source
- /agents/harnesses/think/client-tools/ - Source
- /agents/harnesses/think/configuration/ - Source
- /agents/harnesses/think/getting-started/ - Source
- /agents/harnesses/think/ - Source
- /agents/harnesses/think/messengers/ - Source
- /agents/harnesses/think/programmatic-submissions/ - Source
- /agents/harnesses/think/recovery/ - Source
- /agents/harnesses/think/scheduled-tasks/ - Source
- /agents/harnesses/think/sub-agents/ - Source
- /agents/harnesses/think/tools/ - Source
- /agents/harnesses/think/workflows/ - Source
- /agents/model-context-protocol/apis/agent-api/ - Source
- /agents/model-context-protocol/apis/client-api/ - Source
- /agents/model-context-protocol/apis/handler-api/ - Source
- /agents/model-context-protocol/guides/connect-mcp-client/ - Source
- /agents/model-context-protocol/guides/oauth-mcp-client/ - Source
- /agents/model-context-protocol/guides/securing-mcp-server/ - Source
- /agents/model-context-protocol/protocol/codemode/ - Source
- /agents/model-context-protocol/protocol/tools/ - Source
- /agents/model-context-protocol/protocol/transport/ - Source
- /agents/runtime/communication/http-sse/ - Source
- /agents/runtime/communication/protocol-messages/ - Source
- /agents/runtime/communication/readonly-connections/ - Source
- /agents/runtime/communication/routing/ - Source
- /agents/runtime/communication/websockets/ - Source
- /agents/runtime/execution/agent-skills/ - Source
- /agents/runtime/execution/agent-tools/ - Source
- /agents/runtime/execution/chat-sdk/ - Source
- /agents/runtime/execution/queue-tasks/ - Source
- /agents/runtime/execution/retries/ - Source
- /agents/runtime/execution/run-workflows/ - Source
- /agents/runtime/execution/schedule-tasks/ - Source
- /agents/runtime/execution/sub-agents/ - Source
- /agents/runtime/lifecycle/callable-methods/ - Source
- /agents/runtime/lifecycle/get-current-agent/ - Source
- /agents/runtime/lifecycle/sessions/ - Source
- /agents/runtime/lifecycle/state/ - Source
- /agents/runtime/operations/configuration/ - Source
- /agents/runtime/operations/cross-domain-authentication/ - Source
- /agents/runtime/operations/observability/ - Source
- /agents/runtime/operations/using-ai-models/ - Source
- /agents/tools/ai-search/ - Source
- /agents/tools/browser/ - Source
- /agents/tools/mcp/ - Source
- /agents/tools/sandbox/ - Source
- /ai-gateway/integrations/vercel-ai-sdk/ - Source
- /ai-gateway/integrations/worker-binding-methods/ - Source
- /ai-gateway/observability/custom-metadata/ - Source
- /ai-gateway/usage/providers/workersai/ - Source
- /ai-search/how-to/bring-your-own-generation-model/ - Source
- /ai-search/how-to/per-tenant-search/ - Source
- /ai-search/how-to/simple-search-engine/ - Source
- /artifacts/api/workers-binding/ - Source
- /artifacts/concepts/best-practices/ - Source
- /artifacts/examples/isomorphic-git/ - Source
- /artifacts/examples/sandbox-sdk-artifacts/ - Source
- /artifacts/get-started/workers/ - Source
- /bots/workers-templates/delay-action/ - Source
- /browser-run/features/reuse-sessions/ - Source
- /browser-run/how-to/browser-run-with-do/ - Source
- /browser-run/puppeteer/ - Source
- /cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/ - Source
- /cloudflare-one/access-controls/applications/http-apps/authorization-cookie/validating-json/ - Source
- /cloudflare-one/tutorials/access-workers/ - Source
- /cloudflare-one/tutorials/detect-mcp-traffic-gateway-logs/ - Source
- /containers/container-class/ - Source
- /containers/examples/r2-fuse-mount/ - Source
- /d1/get-started/ - Source
- /d1/tutorials/build-a-comments-api/ - Source
- /durable-objects/api/base/ - Source
- /durable-objects/api/container/ - Source
- /durable-objects/api/legacy-kv-storage-api/ - Source
- /durable-objects/api/sqlite-storage-api/ - Source
- /durable-objects/best-practices/rules-of-durable-objects/ - Source
- /durable-objects/best-practices/websockets/ - Source
- /durable-objects/examples/readable-stream/ - Source
- /durable-objects/examples/testing-with-durable-objects/ - Source
- /durable-objects/examples/websocket-hibernation-server/ - Source
- /durable-objects/examples/websocket-server/ - Source
- /durable-objects/get-started/ - Source
- /dynamic-workers/examples/codemode/ - Source
- /dynamic-workers/examples/dynamic-workers-playground/ - Source
- /dynamic-workers/examples/dynamic-workers-starter/ - Source
- /dynamic-workers/getting-started/ - Source
- /dynamic-workers/usage/durable-object-facets/ - Source
- /dynamic-workers/usage/dynamic-workflows/ - Source
- /dynamic-workers/usage/static-assets/ - Source
- /flagship/binding/ - Source
- /flagship/configuration/ - Source
- /flagship/get-started/ - Source
- /flagship/reference/evaluation-reasons/ - Source
- /flagship/sdk/client-provider/ - Source
- /flagship/sdk/server-provider/ - Source
- /fundamentals/reference/markdown-for-agents/ - Source
- /hyperdrive/concepts/connection-lifecycle/ - Source
- /images/examples/watermark-from-kv/ - Source
- /images/optimization/hosted-images/serve-private-images/ - Source
- /images/optimization/transformations/bindings/ - Source
- /images/storage/upload-images/upload-file-worker/ - Source
- /images/tutorials/optimize-user-uploaded-image/ - Source
- /pipelines/streams/writing-to-streams/ - Source
- /queues/configuration/batching-retries/ - Source
- /queues/configuration/javascript-apis/ - Source
- /queues/configuration/pull-consumers/ - Source
- /r2/objects/upload-objects/ - Source
- /realtime/agents/getting-started/ - Source
- /sandbox/api/backups/ - Source
- /sandbox/api/commands/ - Source
- /sandbox/api/file-watching/ - Source
- /sandbox/api/files/ - Source
- /sandbox/api/interpreter/ - Source
- /sandbox/api/lifecycle/ - Source
- /sandbox/api/ports/ - Source
- /sandbox/api/sessions/ - Source
- /sandbox/api/storage/ - Source
- /sandbox/api/terminal/ - Source
- /sandbox/api/tunnels/ - Source
- /sandbox/configuration/sandbox-options/ - Source
- /sandbox/guides/background-processes/ - Source
- /sandbox/guides/backup-restore/ - Source
- /sandbox/guides/browser-terminals/ - Source
- /sandbox/guides/code-execution/ - Source
- /sandbox/guides/docker-in-docker/ - Source
- /sandbox/guides/execute-commands/ - Source
- /sandbox/guides/expose-services/ - Source
- /sandbox/guides/file-watching/ - Source
- /sandbox/guides/git-workflows/ - Source
- /sandbox/guides/manage-files/ - Source
- /sandbox/guides/mount-buckets/ - Source
- /sandbox/guides/outbound-traffic/ - Source
- /sandbox/guides/proxy-requests/ - Source
- /sandbox/guides/streaming-output/ - Source
- /sandbox/guides/websocket-connections/ - Source
- /sandbox/guides/workers-connections/ - Source
- /sandbox/tutorials/persistent-storage/ - Source
- /stream/manage-video-library/bindings/ - Source
- /stream/viewing-videos/securing-your-stream/ - Source
- /workers-ai/features/function-calling/embedded/get-started/ - Source
- /workers-ai/features/markdown-conversion/usage/binding/ - Source
- /workers-ai/get-started/workers-wrangler/ - Source
- /workers/best-practices/workers-best-practices/ - Source
- /workers/ci-cd/builds/deploy-hooks/ - Source
- /workers/configuration/environment-variables/ - Source
- /workers/configuration/secrets/ - Source
- /workers/development-testing/ - Source
- /workers/development-testing/local-dev-tunnels/ - Source
- /workers/examples/analytics-engine/ - Source
- /workers/examples/spa-shell/ - Source
- /workers/framework-guides/web-apps/tanstack-start/ - Source
- /workers/platform/limits/ - Source
- /workers/reference/migrate-to-module-workers/ - Source
- /workers/runtime-apis/bindings/service-bindings/rpc/ - Source
- /workers/runtime-apis/nodejs/dns/ - Source
- /workers/runtime-apis/nodejs/net/ - Source
- /workers/runtime-apis/nodejs/timers/ - Source
- /workers/runtime-apis/rpc/ - Source
- /workers/runtime-apis/scheduler/ - Source
- /workers/static-assets/migration-guides/migrate-from-pages/ - Source
- /workers/static-assets/routing/single-page-application/ - Source
- /workers/static-assets/routing/worker-script/ - Source
- /workers/testing/vitest-integration/write-your-first-test/ - Source
- /workers/vite-plugin/reference/api/ - Source
- /workflows/build/call-workflows-from-pages/ - Source
- /workflows/build/events-and-parameters/ - Source
- /workflows/build/rules-of-workflows/ - Source
- /workflows/build/trigger-workflows/ - Source
- /workflows/build/workers-api/ - Source
Partials
- src/content/partials/browser-run/example-quick-action-binding.mdx
- src/content/partials/workers/navigation_requests.mdx
- src/content/partials/workers/request-signal-example.mdx
- src/content/partials/workers/service-binding-rpc-example.mdx
- src/content/partials/workers/service-binding-rpc-functions-example.mdx
The TypeScriptExample component uses ts-blank-space ↗ to remove TypeScript-specific syntax from your example and provide a JavaScript tab. This reduces maintenance burden by only having a single example to maintain.
This component is automatically used in the GitHubCode component when the lang is set to ts.
2 collapsed lines
// comment to demonstrate// collapsible sections
export default { async fetch(req, env, ctx) { if (req !== "POST") { return new Response("Method Not Allowed", { status: 405, headers: { Allow: "POST", }, }); }
await env.KV.put("foo", "bar");
return new Response(); },};2 collapsed lines
// comment to demonstrate// collapsible sectionsinterface Environment { KV: KVNamespace;}
export default { async fetch(req, env, ctx): Promise<Response> { if (req !== "POST") { return new Response("Method Not Allowed", { status: 405, headers: { "Allow": "POST" } }); }
await env.KV.put("foo", "bar");
return new Response(); }} satisfies ExportedHandler<Environment>import { TypeScriptExample } from "~/components";
<TypeScriptExample code={{ collapse: "1-2"}}>```ts// comment to demonstrate// collapsible sectionsinterface Environment { KV: KVNamespace;}
export default { async fetch(req, env, ctx): Promise<Response> { if (req !== "POST") { return new Response("Method Not Allowed", { status: 405, headers: { "Allow": "POST" } }); }
await env.KV.put("foo", "bar");
return new Response(); }} satisfies ExportedHandler<Environment>```</TypeScriptExample>type: string
An optional filename, ending in .ts.
.ts will be replaced by .js for the JavaScript tab.
type: boolean
If set to true, a Run Worker in Playground button will appear on the JavaScript tab.
type: object
Props to pass to the Expressive Code component ↗.
These props will apply to both code blocks and so options like collapse may not work as expected, as lines may be removed from the TypeScript code.