Can you show your app.js file?
showing only @routes in fresh Inertia app
Has anyone experienced this error before in a fresh Inertia app?
What I did was (in order):
- Install a fresh Laravel app (8.x)
- Install Laravel Breeze
-
php artisan breeze:install vue- Breeze with Inertia
-
- Install Inertia for Laravel
-
composer require inertiajs/inertia-laravel
-
- Run
npm installandnpm run dev, I also runnpm run watch
But after visiting my app's index page, it only shows me @routes as seen in the image below:
https://ibb.co/N2hQjT8
My .env config
I am using a virtual host, (note: I also tried php artisan serve but it's the same result)
APP_URL=http://vilt.test
My app.js
import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.mixin({ methods: { route } })
.mount(el);
},
});
InertiaProgress.init({ color: '#4B5563' });
My package.json
"devDependencies": {
"@inertiajs/inertia": "^0.10.0",
"@inertiajs/inertia-vue3": "^0.5.1",
"@inertiajs/progress": "^0.2.6",
"@tailwindcss/forms": "^0.4.0",
"@vue/compiler-sfc": "^3.0.5",
"autoprefixer": "^10.4.0",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.4.5",
"postcss-import": "^14.0.1",
"tailwindcss": "^3.0.7",
"vue": "^3.0.5",
"vue-loader": "^16.1.2"
}
My composer.json
"require": {
"php": "^8.0",
"inertiajs/inertia-laravel": "^0.4.5",
"laravel/framework": "^8.76|^8.0",
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",
"barryvdh/laravel-ide-helper": "^2.10",
"laravel/breeze": "^1.6",
"laravel/sail": "^1.0.1",
},
My app.blade.php this is the default
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title inertia>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<!-- Scripts -->
@routes
<script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="font-sans antialiased">
@inertia
@env ('local')
<script src="http://localhost:8080/js/bundle.js"></script>
@endenv
</body>
</html>
For reference, this article is the same problem with me, unfortunately it has no answers https://laravelquestions.com/2021/10/15/empty-page-showing-only-routes-text-comes-out-when-using-laravel8-inertia-vue-js-together/
OS: Windows 10
Laravel version: 8.x
PHP version: 8.x
@benjamin1509 ok. I just tested and I had it installed automatically when I ran php artisan breeze:install vue
Please or to participate in this conversation.