inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.3k stars 423 forks source link

Update the Official documentation. #1934

Closed SantiSnow closed 2 months ago

SantiSnow commented 2 months ago

Versions:

Latest Laravel/InertiaJS version

Describe the problem:

The documentation does not reflect all the necessary steps to correctly install Inertia in a clean Laravel application. Missing: -An app.blade.php file must be created at the root of view folder with the inertia directives. Not Welcome.blade.php as Laravel by default creates. This is not specified in the official documentation. -@vitejs/plugin-vue must be installed to run. This is not specified in the official documentation. -The file vite.config.js must be updated with the following:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        vue(),
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});

Otherwise installation fails. This is not specified anywhere.

These steps should be specified either in the official documentation or in the Readme of the project, I suggest.

Steps to reproduce:

Tested in a fresh installation of Laravel. The official documentation leads to multiple errors: -$page is not defined -View [app] not found laravel inertia fresh install -Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle?

All of these are easily fixed with 15-20 minutes of google search with answers in SO or github, but still should be updated.

RobertBoes commented 2 months ago

Probably a better place would be on the documentation itself: inertiajs/inertiajs.com

An app.blade.php file must be created at the root of view folder with the inertia directives. Not Welcome.blade.php as Laravel by default creates. This is not specified in the official documentation.

This is described in the documentation: https://inertiajs.com/server-side-setup#root-template

About the Vue plugin, that's not really part of Inertia, the Vue plugin is required to use Vue. I do agree, a section that would refer to the Vue/React/Svelte docs on how to set it up would be nice. Inertia is a router in between your frontend (Vue) and backend (Laravel). So you should always consult the docs of those frameworks too. Just like Inertia would deal with props/data coming from the database, but it shouldn't explain how to setup a database and setup Eloquent properly, that's documented in the Laravel docs.

SantiSnow commented 2 months ago

I didn't actually see the part of the app.blade.php, you are right.

What I don't agree with, is the Vue plugin part. As Inertia is described as the "glue" between Vue/React/Svelte and Laravel, a section indicating how to configure it along them is completely necessary. You show not need to consult more documentation outside Inertia.JS, specially with errors like this where the answer is not very clear. Just a clear "How to install" after a clean Laravel installation.

Maybe a better readme would help in this cases, this is a tool I really like using and I think a better documentation with common error cases would help to attract even more people.

Edit: Btw, I didn't know the official website, the documentation page was open source and a public repo. I will try contribute with a PR there.