# Self Hosting

Hypercast runs on Cloudflare, so if you don't have an account, set one up first. You'll also need to install their CLI tool `wrangler` andl log in.

### Creating your instance

This is all the code it takes to run a simple instance:

```typescript
import { Operator } from 'hypercast/server'
export { Hypercast } from 'hypercast/server'
export default new Operator()
```

To deploy to Cloudflare, you'll also need a `wrangler.toml` config file.

```toml
name = "my-hypercast"
main = "src/index.ts"

account_id = 'abcdefg1234567'
compatibility_date = "2022-12-03"

[durable_objects]
  bindings = [
    { name = "hypercasts", class_name = "Hypercast" }
  ]

[[migrations]]
  tag = "init_hypercast"
  new_classes = ["Hypercast"]
```

With that, simply run `wrangler publish`.

### Connecting to your instance

To connect a Hypercast client to your server instance, we'll need it's URL.

```typescript
import { Operator, Hypercast } from 'hypercast/client'

const operator = new Operator('https://my-hypercast.org.workers.dev')

// or

const hypercast = new Hypercast(topic, 'https://my-hypercast.org.workers.dev')
```
