Here goes some relevant peices:
app.js
// require('./bootstrap');
import { createApp, h } from 'vue';
import { createInertiaApp,Head, Link } from '@inertiajs/inertia-vue3';
import AppLayout from '@/Layouts/AppLayout.vue';
import { InertiaProgress } from '@inertiajs/progress';
import AppFilters from './library/filters'
import mitt from 'mitt'
import * as helpers from "./library/helpers";
const emitter = mitt()
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'POS';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
const system = createApp({ render: () => h(app, props) })
.use(plugin)
.component('AppLayout', AppLayout)
.component('InertiaHead', Head)
.component('InertiaLink', Link)
.mixin({ methods: { route } })
system.provide('emitter', emitter)
system.config.globalProperties.$filters = AppFilters
system.config.globalProperties.helpers = helpers.default
return system.mount(el);
},
});
InertiaProgress.init({ color: '#4B5563' });
Then, within my app.blade file:
<html>
<head>
...
<!-- Scripts -->
@routes
<script src="{{ mix('js/app.js') }}" defer></script>
@inertiaHead
</head>
<body class="...">
@inertia
</body>
</html>
A default mix file:
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js').vue()
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
])
.alias({
'@': 'resources/js',
})
if (mix.inProduction()) {
mix.version();
}
The rest in a default implementation of the inertia link tag like so:
<template>
<inertia-link
:href="route('profile.show')"
:class="[
route().current('profile.show') ? 'active styles' :'in-active styles' '',
'default styles',
]">Your Profile</inertia-link>
</template>
<script setup>
// <inertia-link> already made global in app.js
</script>