# Run browser operations on Cloudflare with ViteHub

Use Cloudflare Browser Run when a Worker needs a remote browser. You call each
Browser Definition (one browser operation in a file) with `runBrowser()`.

First, create the `page-html` operation and its POST route in
[Run your first Browser Definition](https://vitehub.dev/docs/browser/get-started). You need a
Cloudflare account with Browser Run access. Remote mode uses the paid service
even in local Wrangler dev.

## Select remote browser access

### Nuxt

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['vite-hub/nuxt'],
  vitehub: {
  	preset: 'cloudflare',
  	browser: { remote: true },
  },
})
```

### Nitro

```ts [vite.config.ts]
import { defineConfig } from 'vite'
import { nitro } from 'nitro/vite'
import { vitehub } from 'vite-hub'

export default defineConfig({
	plugins: [vitehub({
		preset: 'cloudflare',
		browser: { remote: true },
	}), nitro()],
})
```

### Vite

```ts [vite.config.ts]
import { defineConfig } from 'vite'
import { vitehub } from 'vite-hub'

export default defineConfig({
	plugins: [vitehub({
		preset: 'cloudflare',
		browser: { remote: true },
	})],
})
```

Keep Browser operations in `server/browsers/`. A Definition gets the
provider's browser, and your code calls it by name.

## Check the generated binding

Install Wrangler, log in to the account with Browser Run, then build and run
the Worker:

```bash [Terminal]
pnpm add -D wrangler
pnpm wrangler login
pnpm build
pnpm wrangler dev --config .output/server/wrangler.json
```

In another terminal, call the tutorial route:

```bash [Terminal]
curl --fail-with-body http://localhost:8787/api/page-html \
  -H 'content-type: application/json' \
  -d '{"url":"https://example.com"}'
```

The response is the rendered page HTML. Check the status before you read the
body: a provider or discovery error returns a non-2xx status.

## Limit remote access

> **Warning**

The tutorial route opens any URL. Before you publish it, add authentication
and limit the URLs it can open.

This guide uses the built-in Cloudflare provider, not Browserbase. For local
Chromium, see [Browser hosts](https://vitehub.dev/docs/browser/hosts). For timeouts, concurrency,
and account limits, read
[Browser limits](https://vitehub.dev/docs/browser/limits-and-errors) and the
[Cloudflare Browser Run docs](https://developers.cloudflare.com/browser-rendering/).

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/guides.md)
- [Agents](https://vitehub.dev/raw/docs/guides/deploy-agent-cloudflare-vercel.md)
- [Chat bots](https://vitehub.dev/raw/docs/guides/slack-ai-bot.md)
- [Storage](https://vitehub.dev/raw/docs/guides/upstash-redis.md)
- [Databases](https://vitehub.dev/raw/docs/guides/turso.md)
- Server work
  - [Resend](https://vitehub.dev/raw/docs/guides/resend.md)
  - [Cloudflare Browser Run](https://vitehub.dev/raw/docs/guides/cloudflare-browser.md) (this page)
  - [Sandbox providers](https://vitehub.dev/raw/docs/guides/sandbox-providers.md)
  - [Background jobs](https://vitehub.dev/raw/docs/guides/background-jobs.md)
  - [Vercel Queues](https://vitehub.dev/raw/docs/guides/vercel-queues.md)
  - [Cloudflare Queues](https://vitehub.dev/raw/docs/guides/cloudflare-queues.md)
  - [Vercel Cron Jobs](https://vitehub.dev/raw/docs/guides/vercel-cron-jobs.md)
- [Better Auth on Cloudflare](https://vitehub.dev/raw/docs/guides/better-auth-cloudflare.md)
- [Concepts](https://vitehub.dev/raw/docs/guides/rate-limiting-algorithms.md)

Next: [Sandbox providers](https://vitehub.dev/raw/docs/guides/sandbox-providers.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
