Phoenix.LiveDashboard.Router (LiveDashboard v0.4.0) View Source

Provides LiveView routing for LiveDashboard.

Link to this section Summary


Defines a LiveDashboard route.

Link to this section Functions

Link to this macro

live_dashboard(path, opts \\ [])

View Source (macro)

Defines a LiveDashboard route.

It expects the path the dashboard will be mounted at and a set of options.


  • :live_socket_path - Configures the socket path. it must match the socket "/live", Phoenix.LiveView.Socket in your endpoint.

  • :csp_nonce_assign_key - an assign key to find the CSP nonce value used for assets Supports either atom() or %{optional(:img) => atom(), optional(:script) => atom(), optional(:style) => atom()}

  • :ecto_repos - the repositories to show database information. Currently only PSQL databases are supported

  • :env_keys - Configures environment variables to display. It is defined as a list of string keys. If not set, the environment information will not be displayed.

  • :metrics - Configures the module to retrieve metrics from. It can be a module or a {module, function}. If nothing is given, the metrics functionality will be disabled.

  • :metrics_history - Configures a callback for retreiving metric history. It must be an "MFA" tuple of {Module, :function, arguments} such as metrics_history: {MyStorage, :metrics_history, []} If not set, metrics will start out empty/blank and only display data that occurs while the browser page is open.

  • :request_logger_cookie_domain - Configures the domain the request_logger cookie will be written to. It can be a string or :parent atom. When a string is given, it will directly set cookie domain to the given value. When :parent is given, it will take the parent domain from current endpoint host (if host is "" the cookie will be scoped on ""). When not set, the cookie will be scoped to current domain.

  • :allow_destructive_actions - When true, allow destructive actions directly from the UI. Defaults to false. The following destructive actions are available in the dashboard:

    • "Kill process" - a "Kill process" button on the process modal Note that custom pages given to "Additional pages" may support their own destructive actions.
  • :additional_pages - A keyword list of addictional pages


defmodule MyAppWeb.Router do
  use Phoenix.Router
  import Phoenix.LiveDashboard.Router

  scope "/", MyAppWeb do
    pipe_through [:browser]
    live_dashboard "/dashboard",
      metrics: {MyAppWeb.Telemetry, :metrics},
      env_keys: ["APP_USER", "VERSION"],
      metrics_history: {MyStorage, :metrics_history, []},
      request_logger_cookie_domain: ""