Skip to content


This helper function generates a URL based on a route name and the provided arguments.

RelatedRouting, useRoute


function route<T extends RouteName>(
  name: T,
  parameters?: RouteParameters<T>,
  absolute?: boolean
): string

route requires at least a route name. It accepts the route's parameters as the second argument, and a boolean that determines if the URL should be absolute, which is the default, as the third.

The route name and parameters have TypeScript support through the Vite plugin. To learn how to set it up, read the routing documentation.


  • If the route has mandatory parameters and they are not provided, the route function will throw an error.
  • This function returns a non-reactive string. To make it reactive, wrap it in a computed property or use a watcher.


The example below shows how to generate a URL based on a defined route.

// routes/web.php
Route::get('/users/{user}', [UsersController::class, 'show'])
<script setup lang="ts">
const $props = defineProps<{
  user: App.Data.UserData

const index = route('', { user: $props.user })