### Install dependencies and start development server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/style-guide/contributions.mdx Installs the required package dependencies and starts the local documentation development server with hot reloading. ```bash pnpm install pnpm run dev ``` -------------------------------- ### Install dependencies and run dev server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/getting-started/quick-start.mdx Navigate into the newly created project folder, install dependencies, and start the local development server. ```sh cd agents-starter npm install npm run dev ``` -------------------------------- ### Install Vite globally and start development server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/quickstart.mdx Use this alternative command when running the project from the ready-made template. ```bash npm i -g vite && npm run dev ``` -------------------------------- ### Example response with ssl.settings Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/cloudflare-for-platforms/cloudflare-for-saas/performance/early-hints-for-saas.mdx This is an example response from the GET request. It shows the ssl.settings object with early_hints set to "off". Copy the complete object to modify it. ```json { "ssl": { "settings": { "ciphers": [ "ECDHE-ECDSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256" ], "early_hints": "off", "http2": "on", "min_tls_version": "1.2", "tls_1_3": "on" } } } ``` -------------------------------- ### Install and start HTTPD on EC2 Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/ssl/origin-configuration/authenticated-origin-pull/aws-alb-integration.mdx Installs the HTTPD daemon using yum and starts the service on an Amazon Linux EC2 instance. Run this during target instance setup before configuring the ALB target group. ```bash sudo yum install -y httpd sudo systemctl start httpd ``` -------------------------------- ### Run the quickstart script Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/ai-search/get-started/python.mdx Executes quickstart.py to run the instance creation, upload, and search sequence. ```sh python quickstart.py ``` -------------------------------- ### Install Claude Code CLI Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agent-setup/claude-code.mdx Install the Claude Code CLI using the official install script. For Windows, Homebrew, WinGet, or npm, see the Claude Code setup guide. ```bash curl -fsSL https://claude.ai/install.sh | bash ``` -------------------------------- ### Install the Codex CLI with npm Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agent-setup/codex.mdx Installs the Codex CLI globally. macOS and Linux are fully supported; use WSL2 on Windows. For Homebrew or other install methods, see the Codex CLI setup guide. ```bash npm install -g @openai/codex ``` -------------------------------- ### Specify a framework version in package.json Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/configuration/build-image.mdx Use this to pin a specific framework version in the project's package manager configuration file. For example, Gatsby version 5.13.7 will be installed using npm install when the build starts, unless already cached. ```json "dependencies": { "gatsby": "^5.13.7", } ``` -------------------------------- ### Navigate to the project directory Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/tutorials/postgres.mdx Switch into the newly created `postgres-tutorial` directory after scaffolding the Worker application. ```sh cd postgres-tutorial ``` -------------------------------- ### Install the Flagship Go SDK with go get Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/flagship/sdk/go.mdx Install the Go SDK package using go get before configuring the provider. ```sh go get github.com/cloudflare/flagship/sdks/go ``` -------------------------------- ### Initialize a new Sphinx project with sphinx-quickstart Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-sphinx-site.mdx Runs sphinx-quickstart inside the active virtual environment and answers prompts for directory setup, project name, author, release, and language. ```sh sphinx-quickstart ``` ```sh output Separate source and build directories (y/n) [n]: Y Project name: Author name(s): Project release []: Project language [en]: ``` -------------------------------- ### Prepare the Pocket Radio repository checkout Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/sfu/examples/embedded-devices.mdx Clone the realtime-examples repository, navigate to the esp32-radio directory, execute the setup script, and copy the example credentials configuration file. ```sh git clone https://github.com/cloudflare/realtime-examples.git cd realtime-examples/esp32-radio make setup cp .credential.env.example .credential.env ``` -------------------------------- ### Install Browser and PiHarness on a Durable Object Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/tools/browser.mdx Defines a BrowserAssistant Durable Object that installs a Browser and PiHarness, letting Pi choose when to call the browser tool. Lifecycle starts both components and provides their storage. The example uses one named assistant for demonstration; in an application, choose an object name for each authenticated user or workspace. ```ts import { DurableObject } from "cloudflare:workers"; import { createModels } from "@earendil-works/pi-ai/models"; import { createRegistry, Harness } from "@earendil-works/pi-durable"; import { Browser, browserRun } from "agents/browser"; import { browserTool } from "agents/browser/pi"; import { PiHarness } from "agents/harness/pi"; import { Lifecycle } from "agents/lifecycle"; import { createAI } from "agents/models/pi-ai"; export { CodemodeRuntime } from "agents/browser"; export class BrowserAssistant extends DurableObject { ai = createAI({ binding: this.env.AI }); browser = new Browser({ provider: browserRun(this.env.BROWSER) }); registry = createRegistry(); harness = new PiHarness({ harness: ({ storage, context }) => { const models = createModels(); models.setProvider(this.ai.provider); this.registry.install({ name: "browser", tools: [ browserTool({ ctx: this.ctx, browser: this.browser, loader: this.env.LOADER, }), ], }); return Harness.open( storage, { models, registry: this.registry }, context, ); }, defaults: { model: this.ai("@cf/moonshotai/kimi-k2.7-code") }, }); lifecycle = Lifecycle.install(this).use(this.browser).use(this.harness); async ask(prompt: string) { const { text } = await this.harness.prompt(prompt); return text; } } export default { async fetch(request: Request, env: Env) { const assistant = env.BrowserAssistant.getByName("demo"); const text = await assistant.ask(await request.text()); return Response.json({ text }); }, } satisfies ExportedHandler; ``` -------------------------------- ### Create and run agents-starter project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/changelog/agents/2025-03-18-npm-i-agents.mdx Initialize and run the `agents-starter` example template using `npm create cloudflare@latest`. ```sh # Install it $ npm create cloudflare@latest agents-starter -- --template="cloudflare/agents-starter" # Run it $ npm run start ``` -------------------------------- ### Create and initialize project with uv and dependencies Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/basin-catalog/get-started.mdx Sets up a project directory, initializes a uv environment creating .venv and pyproject.toml, and adds marimo, pyiceberg, pyarrow, and pandas. ```bash mkdir r2-data-catalog-notebook ``` ```bash cd r2-data-catalog-notebook ``` ```text uv init ``` ```py uv add marimo pyiceberg pyarrow pandas ``` -------------------------------- ### Install the Cloudflare SDK Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/cloudflare-for-platforms/workers-for-platforms/reference/platform-examples.mdx Install the official Cloudflare npm package before using the TypeScript SDK examples. ```sh npm install cloudflare ``` -------------------------------- ### Test D1 Worker Binding APIs in index.js Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/d1/worker-api/index.mdx Routes incoming requests based on the URL pathname to test various D1 Worker Binding API methods such as run, raw, first, batch, exec, and withSession. Replaces the contents of index.js following the initial Get started setup. ```js // D1 API Playground - Test each D1 Worker Binding API method // Change the URL pathname to test different methods (e.g., /RUN, /RAW, /FIRST) export default { async fetch(request, env) { const { pathname } = new URL(request.url); // Sample data for testing const companyName1 = `Bs Beverages`; const companyName2 = `Around the Horn`; // Prepare reusable statements const stmt = env.DB.prepare(`SELECT * FROM Customers WHERE CompanyName = ?`); const stmtMulti = env.DB.prepare(`SELECT * FROM Customers; SELECT * FROM Customers WHERE CompanyName = ?`); const session = env.DB.withSession("first-primary") const sessionStmt = session.prepare(`SELECT * FROM Customers WHERE CompanyName = ?`); // Test D1PreparedStatement::run - returns full D1Result object if (pathname === `/RUN`){ const returnValue = await stmt.bind(companyName1).run(); return Response.json(returnValue); // Test D1PreparedStatement::raw - returns array of arrays } else if (pathname === `/RAW`){ const returnValue = await stmt.bind(companyName1).raw(); return Response.json(returnValue); // Test D1PreparedStatement::first - returns first row only } else if (pathname === `/FIRST`){ const returnValue = await stmt.bind(companyName1).first(); return Response.json(returnValue); // Test D1Database::batch - execute multiple statements } else if (pathname === `/BATCH`) { const batchResult = await env.DB.batch([ stmt.bind(companyName1), stmt.bind(companyName2) ]); return Response.json(batchResult); // Test D1Database::exec - execute raw SQL without parameters } else if (pathname === `/EXEC`){ const returnValue = await env.DB.exec(`SELECT * FROM Customers WHERE CompanyName = "Bs Beverages"`); return Response.json(returnValue); // Test D1 Sessions API with read replication } else if (pathname === `/WITHSESSION`){ const returnValue = await sessionStmt.bind(companyName1).run(); console.log("You're now using D1 Sessions!") return Response.json(returnValue); } // Default response with instructions return new Response( `Welcome to the D1 API Playground! \nChange the URL to test the various methods inside your index.js file.`, ); }, }; ``` -------------------------------- ### Clone and install privacypass-ts repository Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/privacy-pass/getting-started.mdx Clone the repository and install dependencies before running the local Privacy Pass examples. ```sh git clone https://github.com/cloudflare/privacypass-ts.git cd privacypass-ts npm ci ``` -------------------------------- ### Create a new project using eleventy-base-blog Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-an-eleventy-site.mdx Clones the `eleventy-base-blog` starter repository into a local directory, navigates into it, and installs project dependencies. ```sh git clone https://github.com/11ty/eleventy-base-blog.git my-blog-name cd my-blog-name npm install ``` -------------------------------- ### Install cloudflared service to run at login Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/as-a-service/macos.mdx Installs Cloudflare Tunnel as a launch agent that starts whenever you log in, using the configuration in ~/.cloudflared/. ```sh cloudflared service install ``` -------------------------------- ### Create the HTML entry point Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/demos/chatgpt-app.mdx Sets up index.html with the root container element and imports the app entry script. ```html
``` -------------------------------- ### Install and Run cloudflared on macOS Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/cloudflare-one/setup/replace-vpn/device-to-network.mdx Installs the cloudflared connector via Homebrew and starts the service using the provided tunnel token on macOS. ```sh brew install cloudflared && sudo cloudflared service install ``` -------------------------------- ### meeting.self.setupTracks(options) Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/humans/core/api-reference/RTKSelf.md Sets up the local media tracks. ```APIDOC ## meeting.self.setupTracks(options) ### Description Sets up the local media tracks. ### Parameters | Param | Type | Description | | --- | --- | --- | | options | Object | The audio and video options. | | [options.video] | boolean | If true, the video stream is fetched. | | [options.audio] | boolean | If true, the audio stream is fetched. | | [options.forceReset] | boolean | If true, force resets tracks before re-acquiring. | ### Kind Instance method of RTKSelf ``` -------------------------------- ### setUp(theme:) Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/humans/ui-kit/api-reference/ios/app-theme.mdx Applies a custom theme that conforms to AppThemeProtocol to the shared AppTheme instance. ```APIDOC ## setUp(theme:) ### Description Applies a custom theme conforming to `AppThemeProtocol` to the shared AppTheme instance. This overrides the default appearance objects with those provided by the custom theme. ### Method Instance method ### Endpoint `AppTheme.shared.setUp(theme:)` ### Parameters - **theme** (AppThemeProtocol) - Required - An object conforming to `AppThemeProtocol` that defines custom appearance properties. ### Response - **Void** - This method does not return a value. ### Example ```swift import RealtimeKitUI class CustomTheme: AppThemeProtocol { // Implement required appearance properties } let customTheme = CustomTheme() AppTheme.shared.setUp(theme: customTheme) ``` ``` -------------------------------- ### Run the Dynamic Workers Starter locally Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/dynamic-workers/examples/dynamic-workers-starter.mdx Install dependencies and start the local development server. Use these commands to run the starter template on your machine. ```sh npm install npm run dev ``` -------------------------------- ### Custom recording app URL example Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/recording-guide/create-record-app-using-sdks.mdx Example URL provided to the Start Recording API. RealtimeKit appends authToken and config query parameters to this URL. ```txt https://example.com/my-custom-recorder ``` -------------------------------- ### Navigate to the project directory Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/sandbox/sdk/tutorials/analyze-data-with-ai.mdx Switch into the root directory of the newly created project before installing dependencies and developing the application. ```sh cd analyze-data ``` -------------------------------- ### Complete Android video view example in Kotlin Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/humans/core/local-participant.mdx Full activity example showing self-preview video view setup, lifecycle handling, and resource cleanup. ```kotlin import android.os.Bundle import android.widget.FrameLayout import androidx.appcompat.app.AppCompatActivity import io.dyte.core.VideoView class MainActivity : AppCompatActivity() { private lateinit var videoView: VideoView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Get the self-preview video view videoView = meeting.localUser.getSelfPreview() // Add to your layout val container = findViewById(R.id.video_container) container.addView(videoView) // Start rendering videoView.renderVideo() } override fun onPause() { super.onPause() // Stop rendering when activity is paused videoView.stopVideoRender() } override fun onResume() { super.onResume() // Resume rendering when activity is resumed videoView.renderVideo() } override fun onDestroy() { super.onDestroy() // Clean up resources videoView.release() } } ``` -------------------------------- ### Run a preparation command on startup with onStart() and output() Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/containers/guides/execute-commands.mdx Use the onStart() lifecycle hook to execute commands when a Container starts. process.output() buffers standard output and standard error as separate ArrayBuffer instances. ```typescript import { Container } from "@cloudflare/containers"; export class MyContainer extends Container { override async onStart() { const process = await this.ctx.container.exec([ "node", "scripts/prepare.js", ]); const output = await process.output(); const decoder = new TextDecoder(); if (output.exitCode !== 0) { throw new Error( `Container preparation failed: ${decoder.decode(output.stderr)}`, ); } console.log(decoder.decode(output.stdout)); } } ``` -------------------------------- ### Initialize a new Hexo project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-hexo-site.mdx Run `hexo init` to scaffold a new Hexo project and navigate into the project directory. ```sh hexo init my-hexo-site cd my-hexo-site ```