@inertiajs/vue3 3.0.0-beta.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/vue3",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Vue 3 adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@types/lodash-es": "^4.17.12",
|
|
56
|
-
"laravel-precognition": "2.0.0-beta.
|
|
56
|
+
"laravel-precognition": "2.0.0-beta.3",
|
|
57
57
|
"lodash-es": "^4.17.23",
|
|
58
|
-
"@inertiajs/core": "3.0.0-beta.
|
|
58
|
+
"@inertiajs/core": "3.0.0-beta.2"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "pnpm clean && ./build.js && tsc",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: inertia-vue-development
|
|
3
|
-
description: "Develops Inertia.js
|
|
3
|
+
description: "Develops Inertia.js v3 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using <Link>, <Form>, useForm, useHttp, useLayoutProps, or router; working with deferred props, prefetching, optimistic updates, instant visits, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation."
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: laravel
|
|
@@ -15,14 +15,14 @@ metadata:
|
|
|
15
15
|
Activate this skill when:
|
|
16
16
|
|
|
17
17
|
- Creating or modifying Vue page components for Inertia
|
|
18
|
-
- Working with forms in Vue (using `<Form
|
|
18
|
+
- Working with forms in Vue (using `<Form>`, `useForm`, or `useHttp`)
|
|
19
19
|
- Implementing client-side navigation with `<Link>` or `router`
|
|
20
|
-
- Using
|
|
20
|
+
- Using v3 features: deferred props, prefetching, optimistic updates, instant visits, layout props, HTTP requests, WhenVisible, InfiniteScroll, once props, flash data, or polling
|
|
21
21
|
- Building Vue-specific features with the Inertia protocol
|
|
22
22
|
|
|
23
23
|
## Documentation
|
|
24
24
|
|
|
25
|
-
Use `search-docs` for detailed Inertia
|
|
25
|
+
Use `search-docs` for detailed Inertia v3 Vue patterns and documentation.
|
|
26
26
|
|
|
27
27
|
## Basic Usage
|
|
28
28
|
|
|
@@ -293,7 +293,134 @@ function submit() {
|
|
|
293
293
|
@endboostsnippet
|
|
294
294
|
@endverbatim
|
|
295
295
|
|
|
296
|
-
## Inertia
|
|
296
|
+
## Inertia v3 Features
|
|
297
|
+
|
|
298
|
+
### HTTP Requests
|
|
299
|
+
|
|
300
|
+
Use the `useHttp` hook for standalone HTTP requests that do not trigger Inertia page visits. It provides the same developer experience as `useForm`, but for plain JSON endpoints.
|
|
301
|
+
|
|
302
|
+
@boostsnippet("useHttp Example", "vue")
|
|
303
|
+
<script setup>
|
|
304
|
+
import { useHttp } from '@inertiajs/vue3'
|
|
305
|
+
|
|
306
|
+
const http = useHttp({
|
|
307
|
+
query: '',
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
function search() {
|
|
311
|
+
http.get('/api/search', {
|
|
312
|
+
onSuccess: (response) => {
|
|
313
|
+
console.log(response)
|
|
314
|
+
},
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
</script>
|
|
318
|
+
|
|
319
|
+
<template>
|
|
320
|
+
<input v-model="http.query" @input="search" />
|
|
321
|
+
<div v-if="http.processing">Searching...</div>
|
|
322
|
+
</template>
|
|
323
|
+
@endboostsnippet
|
|
324
|
+
|
|
325
|
+
### Optimistic Updates
|
|
326
|
+
|
|
327
|
+
Apply data changes instantly before the server responds, with automatic rollback on failure:
|
|
328
|
+
|
|
329
|
+
@boostsnippet("Optimistic Update with Router", "vue")
|
|
330
|
+
<script setup>
|
|
331
|
+
import { router } from '@inertiajs/vue3'
|
|
332
|
+
|
|
333
|
+
function like(post) {
|
|
334
|
+
router.optimistic((props) => ({
|
|
335
|
+
post: {
|
|
336
|
+
...props.post,
|
|
337
|
+
likes: props.post.likes + 1,
|
|
338
|
+
},
|
|
339
|
+
})).post(`/posts/${post.id}/like`)
|
|
340
|
+
}
|
|
341
|
+
</script>
|
|
342
|
+
@endboostsnippet
|
|
343
|
+
|
|
344
|
+
Optimistic updates also work with `useForm` and the `<Form>` component:
|
|
345
|
+
|
|
346
|
+
@verbatim
|
|
347
|
+
@boostsnippet("Optimistic Update with Form Component", "vue")
|
|
348
|
+
<template>
|
|
349
|
+
<Form
|
|
350
|
+
action="/todos"
|
|
351
|
+
method="post"
|
|
352
|
+
:optimistic="(props, data) => ({
|
|
353
|
+
todos: [...props.todos, { id: Date.now(), name: data.name, done: false }],
|
|
354
|
+
})"
|
|
355
|
+
>
|
|
356
|
+
<input type="text" name="name" />
|
|
357
|
+
<button type="submit">Add Todo</button>
|
|
358
|
+
</Form>
|
|
359
|
+
</template>
|
|
360
|
+
@endboostsnippet
|
|
361
|
+
@endverbatim
|
|
362
|
+
|
|
363
|
+
### Instant Visits
|
|
364
|
+
|
|
365
|
+
Navigate to a new page immediately without waiting for the server response. The target component renders right away with shared props, while page-specific props load in the background.
|
|
366
|
+
|
|
367
|
+
@boostsnippet("Instant Visit with Link", "vue")
|
|
368
|
+
<script setup>
|
|
369
|
+
import { Link } from '@inertiajs/vue3'
|
|
370
|
+
</script>
|
|
371
|
+
|
|
372
|
+
<template>
|
|
373
|
+
<Link href="/dashboard" component="Dashboard">Dashboard</Link>
|
|
374
|
+
|
|
375
|
+
<Link
|
|
376
|
+
href="/posts/1"
|
|
377
|
+
component="Posts/Show"
|
|
378
|
+
:page-props="{ post: { id: 1, title: 'My Post' } }"
|
|
379
|
+
>
|
|
380
|
+
View Post
|
|
381
|
+
</Link>
|
|
382
|
+
</template>
|
|
383
|
+
@endboostsnippet
|
|
384
|
+
|
|
385
|
+
### Layout Props
|
|
386
|
+
|
|
387
|
+
Share dynamic data between pages and persistent layouts:
|
|
388
|
+
|
|
389
|
+
@verbatim
|
|
390
|
+
@boostsnippet("Layout Props in Layout", "vue")
|
|
391
|
+
<script setup>
|
|
392
|
+
import { useLayoutProps } from '@inertiajs/vue3'
|
|
393
|
+
|
|
394
|
+
const layout = useLayoutProps({
|
|
395
|
+
title: 'My App',
|
|
396
|
+
showSidebar: true,
|
|
397
|
+
})
|
|
398
|
+
</script>
|
|
399
|
+
|
|
400
|
+
<template>
|
|
401
|
+
<header>{{ layout.title }}</header>
|
|
402
|
+
<aside v-if="layout.showSidebar">Sidebar</aside>
|
|
403
|
+
<main>
|
|
404
|
+
<slot />
|
|
405
|
+
</main>
|
|
406
|
+
</template>
|
|
407
|
+
@endboostsnippet
|
|
408
|
+
@endverbatim
|
|
409
|
+
|
|
410
|
+
@boostsnippet("Setting Layout Props from Page", "vue")
|
|
411
|
+
<script setup>
|
|
412
|
+
import { setLayoutProps } from '@inertiajs/vue3'
|
|
413
|
+
|
|
414
|
+
setLayoutProps({
|
|
415
|
+
title: 'Dashboard',
|
|
416
|
+
showSidebar: false,
|
|
417
|
+
})
|
|
418
|
+
</script>
|
|
419
|
+
|
|
420
|
+
<template>
|
|
421
|
+
<h1>Dashboard</h1>
|
|
422
|
+
</template>
|
|
423
|
+
@endboostsnippet
|
|
297
424
|
|
|
298
425
|
### Deferred Props
|
|
299
426
|
|
|
@@ -343,7 +470,7 @@ let interval
|
|
|
343
470
|
onMounted(() => {
|
|
344
471
|
interval = setInterval(() => {
|
|
345
472
|
router.reload({ only: ['stats'] })
|
|
346
|
-
}, 5000)
|
|
473
|
+
}, 5000)
|
|
347
474
|
})
|
|
348
475
|
|
|
349
476
|
onUnmounted(() => {
|
|
@@ -378,7 +505,6 @@ defineProps({
|
|
|
378
505
|
<div>
|
|
379
506
|
<h1>Dashboard</h1>
|
|
380
507
|
|
|
381
|
-
<!-- stats prop is loaded only when this section scrolls into view -->
|
|
382
508
|
<WhenVisible data="stats" :buffer="200">
|
|
383
509
|
<template #fallback>
|
|
384
510
|
<div class="animate-pulse">Loading stats...</div>
|
|
@@ -409,3 +535,5 @@ Server-side patterns (Inertia::render, props, middleware) are covered in inertia
|
|
|
409
535
|
- Not handling the `undefined` state of deferred props before data loads
|
|
410
536
|
- Using `<form>` without preventing default submission (use `<Form>` component or `@submit.prevent`)
|
|
411
537
|
- Forgetting to check if `<Form>` component is available in your Inertia version
|
|
538
|
+
- Using `router.cancel()` instead of `router.cancelAll()` (v3 breaking change)
|
|
539
|
+
- Using `router.on('invalid', ...)` or `router.on('exception', ...)` instead of the renamed `httpException` and `networkError` events
|