RxAssim

RxAssim

Hello Elixir community! I’m excited to announce the first release of Routes, a library that automatically generates JavaScript and TypeScript route helpers from your Phoenix router. It aims to bring the convenience and type safety of Phoenix route helpers to your frontend code.

Why Routes?

Working with Phoenix and modern JavaScript frameworks, I often found myself manually maintaining route paths in the frontend or creating custom solutions to keep frontend routing in sync with Phoenix routes. Routes solves this by:

  • :counterclockwise_arrows_button: Automatically generating route helpers from your Phoenix router
  • :memo: Providing full TypeScript support with type definitions
  • :magnifying_glass_tilted_left: Supporting live reloading during development
  • :bullseye: Handling path parameters and query strings with type safety
  • :flexed_biceps: Ensuring route parameters are correctly typed and validated

Quick Example

# In your Phoenix router
defmodule MyAppWeb.Router do
  use Phoenix.Router
  use Routes

  scope "/" do
    get "/users/:id", UserController, :show, as: :user
  end
end
// In your JavaScript/TypeScript code
import Routes from './routes';

// Type-safe route generation
const url = Routes.path('user.show', { id: 123 });
// => "/users/123"

// With query parameters
const searchUrl = Routes.path('user.index', {
  _query: { search: 'john', filter: 'active' }
});
// => "/users?search=john&filter=active"

Inertia.js Integration

If you’re using Inertia.js, Routes provides a clean way to create type-safe navigation:

<Link
  to="/users/:id"
  params={{ id: 123, _query: { tab: "profile" } }}
>
  View Profile
</Link>

Getting Started

Add to your mix.exs:

def deps do
  [
    {:routes, "~> 0.1.0"}
  ]
end

Configure in config.exs:

config :routes,
  router: MyAppWeb.Router,
  typescript: true,
  routes_path: "assets/js/routes"

Links

https://github.com/assimelha/routes

Feedback Welcome!

This is the initial release, and I’d love to hear your thoughts, suggestions, and use cases. Feel free to open issues on GitHub or contribute to the project.

Happy coding! :tada:

Showing Posts 1 to 3

BartOtten

BartOtten

Hi @RxAssim,

Always nice to see people invest time in the eco system! As for the feedback:

  1. Pardon my question but I fail to see the use case. Where does this fit in? When does a server side path need a sync with client side, which can not be (and afaik is) handled by Phoenix LiveView?*

Edit: answer myself: Inertiajs of course :slight_smile:

—-

  1. The name of the lib is a bit too close to my lib RouteX for my taste to be honest and also in the same valley as libs called ‘framework’ or ‘xml’. I would suggest a more distrinct name.

—-

  1. Maybe this can be a Routex extension? This would solve the naming issue, you can focus on the Typescript part (as processing and live regeneration is taken care of) and all features of Routex will be supported by the Typescript files (alternative routes for instance).

Kind regard,
Author of Routex

RxAssim

RxAssim OP

Hi @BartOtten,

  1. Yes, you could use it with Inertia, Live_svelte, Live_vue…
  2. It’s just the simplest name I could think of + this lib is mostly code that I wrote for my own projects and decided to open source it mostly as is.
  3. Seems like a good idea, but Routes is supposed to handle one thing and one thing alone which is easy routes access for frontend frameworks that use Phoenix as a backend.
Muco

Muco

Thank you for this package @RxAssim. Do you know if there’s any package that generates props types?

— All posts loaded —

Where Next? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews