Bun runtime for Phoenix.ReactServer server.
This runtime uses Bun as the JavaScript runtime for rendering React components. Bun provides fast startup times and excellent performance for server-side rendering.
Configuration
Configure in runtime.exs:
import Config
config :phoenix_react_ng, Phoenix.ReactServer.Runtime.Bun,
cd: File.cwd!(),
cmd: System.find_executable("bun"),
# 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.bun.bundle`
server_js: Path.expand("bun/server.js", :code.priv_dir(:phoenix_react_ng)),
port: 5225,
env: :devConfiguration Options
:cd- Working directory for the Bun process (default: current directory):cmd- Path to Bun executable (default: systembuncommand):server_js- Path to the bundled server JavaScript file:port- Port for the Bun HTTP server (default: 5225):env- Environment mode (:devor:prod, default::dev)
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.bun.bundle --component-base=assets/component --output=priv/react/server.js
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the Bun runtime server.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(term()) :: GenServer.on_start()
Starts the Bun runtime server.
Parameters
init_arg- Initialization arguments (typically[])
Returns
{:ok, pid}- Runtime started successfully{:error, reason}- Failed to start runtime