# `Phoenix.ReactServer.Runtime.Deno`
[🔗](https://github.com/mfreeman451/phoenix-react-ng/blob/v0.8.5/lib/phoenix/react_server/runtime/deno.ex#L1)

Deno runtime for Phoenix.ReactServer server.

This runtime uses Deno as the JavaScript runtime for rendering React components.
Deno provides secure defaults, TypeScript support, and excellent performance.

## Configuration

Configure in `runtime.exs`:

```elixir
import Config

config :phoenix_react_ng, Phoenix.ReactServer.Runtime.Deno,
  cd: File.cwd!(),
  cmd: System.find_executable("deno"),
  # In dev mode, the server_js will be watched and recompiled when changed
  # In prod mode, this needs to be precompiled with `mix phx.react.deno.bundle`
  server_js: Path.expand("deno/server.js", :code.priv_dir(:phoenix_react_ng)),
  port: 5226,
  env: :dev,
  # Security: restrict write access to specific directories
  write_dirs: ["/tmp", "/var/tmp"]
```

## Configuration Options

- `:cd` - Working directory for the Deno process (default: current directory)
- `:cmd` - Path to Deno executable (default: system `deno` command)
- `:server_js` - Path to the bundled server JavaScript file
- `:port` - Port for the Deno HTTP server (default: 5226)
- `:env` - Environment mode (`:dev` or `:prod`, default: `:dev`)
- `:write_dirs` - List of directories Deno can write to (security feature)
- `:parent_check_interval` - Interval to check parent process health (default: 5000ms)

## Security Features

Deno runtime provides enhanced security:
- Restricted file system access via `write_dirs`
- Automatic parent process monitoring
- Sandboxed execution environment

## Component Requirements

Components for Deno runtime must:
- Use `.jsx` file extension for proper JSX parsing
- Export a `Component` function
- Be compatible with Deno's module system

## Development Mode

In development mode (`env: :dev`), the runtime will:
- Start a file watcher for component changes
- Automatically rebuild the server bundle when components change
- Enable hot reloading for React components

## Production Mode

In production mode (`env: :prod`), you must pre-bundle the components:

```bash
mix phx.react.deno.bundle --component-base=assets/component --output=priv/react/server.js
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@spec start_link(term()) :: GenServer.on_start()
```

Starts the Deno runtime server.

## Parameters

- `init_arg` - Initialization arguments (typically `[]`)

## Returns

- `{:ok, pid}` - Runtime started successfully
- `{:error, reason}` - Failed to start runtime

---

*Consult [api-reference.md](api-reference.md) for complete listing*
