Building with AdonisJS & Inertia #2.3

The Link Component and Programmatic Linking

In This Lesson

We'll explore Inertia's Link component and its props. We'll then examine how to link between pages programmatically using Inertia's router.

Created by
@tomgobich
Published

Join the Discussion 2 comments

Create a free account to join in on the discussion
  1. @jean-louis

    How can I make use of route identifiers ? Especially for programmatic linking.

    1
    1. Responding to jean-louis
      @tomgobich

      Hi Jean!

      You can achieve that by using Tuyua! From it's documentation, once installed & configured it'll allow template & programmatic linking using route identifiers like the below:

      <script setup lang="ts">
      import { Link, useRouter } from '@tuyau/inertia/vue'
      
      const router = useRouter()
      
      function visit() {
        router.visit('users.posts.show', { id: 1, postId: 2 })
      }
      </script>
      
      <template>
        <div>
          <Link route="users.posts.show" :params="{ id: 1, postId: 2 }">Go to post</Link>
          <button type="button" @click="visit">Go to posts</button>
        </div>
      </template>
      Copied!
      • inertia
      • pages
      • Home.vue
      1