Add a query string to a Wayfinder URL

Pass query on the generated Wayfinder function. Do not glue a question mark onto the URL by hand.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/wayfinder-query-string-vue.md
Pass query on the generated Wayfinder function. Do not glue a question mark onto the URL by hand.
Do not glue a question mark onto the URL by hand.
Do not install Ziggy because a query string felt easier with route().
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Wayfinder query string” concatenate ?search= onto a generated URL and then lose the types. The Wayfinder guide shows store() for a form. A list link is the same generated function, plus the query object the file already accepts.

TL;DR

  • Pass query on the generated Wayfinder function.
  • Do not glue a question mark onto the URL by hand.
  • Do not install Ziggy because a query string felt easier with route().

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3 · TypeScript

The fix#

Open resources/js/actions/.../PostController.ts after php artisan wayfinder:generate. The index function takes an options argument. This is the shape current Wayfinder generates for a route with no parameters:

vue
<script setup lang="ts">
import { Link } from "@inertiajs/vue3";
import { index } from "@/actions/App/Http/Controllers/PostController";

defineProps<{ search: string }>();
</script>

<template>
  <Link :href="index({ query: { search } })">Search</Link>
</template>

If the generated type names the argument differently, follow the file. The generator is the API. An action that already has a route parameter takes that parameter first and the options second, the same way the Wayfinder guide uses update(post.id).

What to avoid#

Gotcha

Do not install Ziggy because a query string felt easier with route(). The Ziggy page is why that package stays out of this kit.

FAQ#

How do I add a query string to a Wayfinder URL?

Pass query on the generated Wayfinder function. Do not glue a question mark onto the URL by hand.

What goes wrong with Wayfinder query string?

Many developers concatenate ?search= onto a generated URL and then lose the types. Do not install Ziggy because a query string felt easier with route().

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.