Links
<Link> visits a page without a full reload:
gts
<Link @href='/posts' @prefetch={{true}}>Posts</Link>
<Link @href='/posts/1' @method='delete' @onBefore={{this.confirm}}>Delete</Link>
<Link @href='/posts' @only={{array 'posts'}} @preserveState={{true}} @reset={{array 'posts'}}>Refresh</Link>Every option from the other adapters is an argument:
| Argument | What it does |
|---|---|
@method, @data, @headers | The request. A link that isn't GET renders a <button>. |
@only, @except, @reset | Partial reloads: which props to ask for, and which to replace. |
@replace, @preserveScroll, @preserveState, @preserveUrl | What the visit keeps. |
@prefetch | true, "hover", "click", "mount", or a list of them. |
@cacheFor, @cacheTags | How long a prefetched page stays fresh, and tags to invalidate it. |
@viewTransition, @async | A view transition, and visits that don't cancel each other. |
@onBefore, @onStart, @onSuccess, @onError, @onFinish… | The visit callbacks. Returning false from @onBefore cancels it. |
While a visit is in flight the element has data-loading, for styling.
In the demo, the nav links prefetch on hover, and the category chips on the Ideas page reload only the list.
Try it ↗Your own element
To turn an element of your own into a link, use the {{inertia}} modifier. It takes the same options:
gts
<a href='/posts' {{inertia prefetch='mount'}}>Posts</a>Visiting from code
router is Inertia's, re-exported:
ts
import { router } from 'inertia-ember';
router.get('/ideas', { q: 'ember' }, { preserveState: true, replace: true });