# `Chime.Router`
[🔗](https://github.com/hattoriai/chime/blob/v0.1.0-dev/lib/chime/router.ex#L1)

Mounts Chime in the app's router.

    import Chime.Router

    scope "/api" do
      pipe_through :api_authenticated
      chime_api "/notifications"
    end

    # The links of the emails: no session, no CSRF token, as a mail
    # client posts the one to unsubscribe (RFC 8058).
    pipeline :mail do
      plug :accepts, ["html"]
    end

    scope "/" do
      pipe_through :mail
      chime_mail "/notifications/mail"
    end

`chime_api/2` mounts the feed and the preferences as JSON, for a
frontend that Phoenix does not render (see `Chime.API` and the
[Any frontend](any_frontend.md) guide), and `chime_mail/2` the
addresses of the emails' links, to unsubscribe and to open a
notification (see `Chime.Router.Mail`), at the config's `:mail_url`.
Each is a library mounted with
[PhoenixMountable](https://hexdocs.pm/phoenix_mountable): ordinary
routes in the app's router (`mix phx.routes` lists them), behind the
app's own scopes and pipelines.

The LiveViews of the app need no mount: `Chime.Live` and
`Chime.Components` go in them.

# `chime_admin`
*macro* 

Mounts the admin at `path`: see `Chime.Router.Admin`.

# `chime_api`
*macro* 

Mounts Chime.Router at `path` in a host router.

    import Chime.Router

    scope "/" do
      pipe_through :browser
      chime_api "/chime"
    end

## Options

* `:token_max_age` (`t:pos_integer/0`) - How long a token of `Chime.Token` is valid, in seconds. The default value is `86400`.

Every mount also takes the options listed in `PhoenixMountable`, such as
`:as`, `:on_mount` and `:csp_nonce_assign_key`.

# `chime_mail`
*macro* 

Mounts the addresses of the emails' links at `path`, the config's
`:mail_url`: see `Chime.Router.Mail`.

---

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