Your first Desktop App
To convert a barebones Phoenix Live View example to a Desktop Application you will need to add this to your application:
Add a Desktop.Window child to your supervision tree on startup. E.g. in
application.exchildren = [{ # After your other children # Starting Desktop.Windows Desktop.Window, [ app: :your_app, id: YourAppWindow, url: &YourAppWeb.Endpoint.url/0 ] }] Supervisor.start_link()In
endpoint.excalluse Desktop.Endpointinstead ofuse Phoenix.Endpointdefmodule YourAppWeb.Endpoint do use Desktop.Endpoint, otp_app: :your_appIn
config.exsensure http is configured and the port is set to0so it's chosen automatically# Configures the endpoint config :your_app, YourAppWeb.Endpoint, http: [ip: {127, 0, 0, 1}, port: 0], server: true, ...For localization and to autodetect the desktop language (optional), add the detection hook to your application startup. E.g. in
application.ex:def start(_type, args) do Desktop.identify_default_locale(YourWebApp.Gettext) children = [ ...