Phoenix 1.4.0 is out with ‘Presence javascript API’, HTTP2 support, and more!

Yesterday, the Phoenix web framework announced the release of its latest version, Phoenix 1.4. This release includes new features such as an HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. The community also shipped a new and improved Presence javascript API.

Features in the Phoenix 1.4.0

phx_new archive via hex

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience. The existing Phoenix applications will continue to work on Elixir 1.4. However, the new phx.new archive requires Elixir 1.5+.

Support HTTP2 by making a small change

Thanks to the release of Cowboy 2, Phoenix 1.4 supports HTTP2 with a single line change to mix.exs. One needs to simply add {:plug_cowboy, “~> 2.0”} to their deps and Phoenix will run with the Cowboy 2 adapter.

New phx.gen.cert to aid local SSL development

Most browsers require connections over SSL for HTTP2 requests, failure of which can cause them to fallback to HTTP 1.1 requests. To aid local development over SSL, Phoenix now includes a new phx.gen.cert task which generates a self-signed certificate for HTTPS testing in development.

Faster Development Compilation

The new release has improved compilation speeds have improved due to the contributions to plug and compile-time changes.

New Development 404 Page

Phoenix’s 404 page (in development) now lists the available routes for the originating router, for example:

A new UserSocket for connection info

Access to more underlying transport information when using Phoenix channels has been a highly requested feature. The 1.4 release now provides a connect/3 UserSocket callback, which can provide connection information, such as the peer IP address, host information, and X-Headers of the HTTP request for WebSocket and Long-poll transports.

New ‘Presence JavaScript API’

A new, backward compatible Presence JavaScript API has been introduced to both resolve race conditions as well as simplify the usage. Previously, multiple channel callbacks against “presence_state” and “presence_diff” events were required on the client which dispatched to Presence.syncState and Presence.syncDiff functions. Now, the interface has been unified to a single onSync callback and the presence object tracks its own channel callbacks and state.