[Vuejs]-Intercepting queried params in vue router

0👍

Query parameters are not considered part of a route’s path. Path should also always start with /. You should define your route as such:

{ path: "/confirmations", component: Component }

The URL /confirmations?confirmation_token=rpSLUPpsHsYxkvYkXY_s should still take you to Component, and everything after ? in the URL will be accessible on the route’s query property.

<script setup>
import { useRoute } from 'vue-router'

const route = useRoute()
const query = route.query // { "confirmation_token": "rpSLUPpsHsYxkvYkXY_s" }
</script>

Query params are nothing you need to specify in your routes file.

Leave a comment