Learn how to use Phoenix's verified routes with the ~p sigil for compile-time route validation
Learn how to use Phoenix’s verified routes with the ~p sigil for compile-time route validation.
~p
sigil (e.g., ~p"/products"
) for route validation and path generationShopWeb
macros~p"/?console=#{console}&admin=true"
or ~p"/?#{[console: "Xbox", admin: true]}"
redirect(conn, to: ~p"/products")
for safe, error-checked redirectsurl()
function and the ~p
path: url(~p"/products")
Always use ~p
(verified route sigil) instead of hardcoded path strings for links and redirects. Guarantees valid routing and safer code in Phoenix apps.