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:
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: systemdenocommand):server_js- Path to the bundled server JavaScript file:port- Port for the Deno HTTP server (default: 5226):env- Environment mode (:devor: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
.jsxfile extension for proper JSX parsing - Export a
Componentfunction - 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:
mix phx.react.deno.bundle --component-base=assets/component --output=priv/react/server.js
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the Deno runtime server.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@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