All Ruby/Rails developers know that for features neither provides, there is probably a Ruby Gem contributed by someone in the community that solves that problem.

Elixir’s equivalent to Ruby Gems are Hex packages. Hex is a package manager that provides reusable libraries for both Elixir and the Erlang ecosystem.

When you first start developing in Elixir it’s hard to track down the best libraries, so here’s my pick after 6 months of Elixir’ing at Drover:

Ecto is the equivalent to Rails’ ActiveRecord. It handles connections to a database, as well as migrations and all that jazz.

Phoenix is Elixir’s more direct equivalent to Rails. It implements the server-side Model View Controller (MVC) pattern and should feel familiar to all Rails devs.

If you hate writing javascript for mundane tasks like form validation and other simple use cases, or if you just want something realtime on the browser without having to worry about the Javascript part of it, then Phoenix LiveView is for you. It’s the new kid on the block and allows for rich user interactions writing only server side code. Check it out.

Broadway is a library that allows you to easily build data processing pipelines in Elixir. It’s data production agnostic and the most common case is to use it with broadway_sqs to consume and process messages from SQS queues (it also supports RabbitMQ and is easily extended).

HTTPoison allows you to perform http requests (similar to HTTParty) and uses Erlang’s hackney under the hood.

If you need a token based authentication mechanism then Guardian is for you. By default JSON Web Tokens are supported out of the box but any token that implements Guardian.Token behaviour can be used.

Speaking of authentication, if you need to provide multiple ways to auth your app — including social login and signup — you probably want something like Ueberauth. Heavily inspired by Omniauth, it allows for many authentication strategies to be used.

Telemetry is a metrics and instrumentation dispatching library. It’s a joint effort by the Erlang community to provide metrics for Erlang and Elixir projects.

Being a dynamic language, types can become tricky in Elixir. The good news is that projects like Norm can help you specify and structure your data to make it conform to any values you expect. Using `conform!` is a great way to assert data structure inside your functions.

Cats are nice, here's a picture of a kitten.

Thwarting abusive web requests is a must nowadays. And you can use PlugAttack for that. It’s inspired by the Rack::Attack middleware for Ruby.

Date and time handling in Elixir/Erlang is not the most usable thing in the world. Thankfully there are libraries like Timex that can help. If you need to manipulate dates, times, datetimes, timestamps, etc., (timezone support included) then Timex is for you.

CORSPlug is a library to provide CORS support as a plug (that can be used in Phoenix), so that different systems can easily interact with your API, even from another domain.

Bonus track: documentation, development and test tools

Here’s a few more libraries, this time dedicated to development time, documentation and testing:

PhoenixSwagger gives you a way to generate Swagger documentation for Phoenix apps. It can also serve a web interface to browse and interact with API documentation that you generate. A must, if you are developing a web API.

If you love to have your code well documented, EXDoc allows you to generate HTML and EPUB docs for it.

Mix Test Watch runs your project tests whenever you change a file. You never need to run tests manually ever again. It’s that awesome.

The perfect complement to that is ExUnitNotifier, which shows you desktop notifications when the tests run with information about pass or fail. You don’t even need to leave your IDE to know if you broke something or not.

You will want to check out Credo as well. It’s a tool similar to Rubocop, that performs static code analysis for best practices. A must have for all projects.

Speaking of static analysis, Dialyzer is a static analysis tool for Erlang and other languages that compile to BEAM byte code for the Erlang VM. It can analyse the BEAM files and provide warnings about problems in your code including type mismatches and other issues that are commonly detected by static language compilers. You can use Dialyxir to simplify using the Dialyzer in Elixir projects.

If you write unit tests in Ruby you probably mocked some classes or method calls at some point. In Elixir you can mock any function call with Mox by using behaviours and explicit contracts.

You probably heard of Brakeman, a security focused gem that analyses your code for vulnerabilities. For Elixir you have Sobelow.

And last, but not least, if you need test coverage reports you can use ExCoveralls for that. It also (optionally) integrates with the coveralls.io service if you track your coverage on the cloud.

If you have any suggestions about other interesting libraries, feel free to share in the comments below.

Happy coding!


Cool Elixir libraries was originally published in Drover Engineering on Medium, where people are continuing the conversation by highlighting and responding to this story.