laravel/vue-starter-kit
Modern Laravel + Vue 3 starter kit powered by Inertia for SPA-like apps with server-side routing. Includes TypeScript, Tailwind CSS, Vite, Composition API, and shadcn-vue components—ideal for quickly bootstrapping a full-stack Laravel app.
Installation
composer create-project laravel/vue-starter-kit my-app
cd my-app
npm install
npm run dev
php artisan serve
http://localhost:8000 by default.First Use Case: Create a Page
php artisan inertia:page Dashboard
resources/js/Pages/Dashboard.vue)app/Http/Controllers/DashboardController.php)routes/web.php)Where to Look First
resources/js/: Vue/TypeScript frontend entry point.resources/js/Pages/: Inertia page components.resources/js/Layouts/: Shared layouts (e.g., AuthenticatedLayout.vue).resources/views/app.blade.php: Root Blade template (renders Vue app).vite.config.ts: Vite configuration (optimizations, plugins).Inertia + Laravel Routing
Route::inertia() for server-side routing:
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
public function index()
{
return Inertia::render('Dashboard', [
'users' => User::all(),
]);
}
<script setup>
defineProps<{
users: User[];
}>();
</script>
Component-Based Development
resources/js/Components/.AuthenticatedLayout.vue for auth-protected pages.<script setup> for cleaner code:
<script setup>
import { ref } from 'vue';
const count = ref(0);
</script>
State Management
php artisan inertia:pinia Auth
import { useAuthStore } from '@/Stores/Auth';
const auth = useAuthStore();
API Calls
axios wrapper (resources/js/bootstrap.ts):
import { router } from '@inertiajs/vue3';
await router.post('/logout');
import axios from '@/Axios';
const response = await axios.get('/api/users');
Tailwind + shadcn-vue
npx shadcn-vue@latest add button
<Button>Click Me</Button>
Testing
npm run test).php artisan test).Inertia Page Caching
npm run dev -- --force
vite.config.ts:
server: { hmr: { host: 'localhost' } }
TypeScript Strictness
tsconfig.json is configured for Vue 3:
{
"compilerOptions": {
"types": ["vite/client"]
}
}
interface PageProps {
flash: { type: string; message: string };
}
shadcn-vue Component Conflicts
resources/views/components/).CSRF Token in API Calls
@csrf in forms or use axios with Laravel’s CSRF cookie:
axios.defaults.withCredentials = true;
Vite HMR Issues
vite.config.ts for misconfigured plugins.Inertia Page Errors
Inertia::render() with correct props.TypeScript Errors
npm run dev with --debug for detailed TS errors.resources/js/shims-vue.d.ts:
declare module '@inertiajs/vue3' {
namespace Inertia {
interface PageProps {}
}
}
Tailwind JIT Issues
tailwind.config.js includes all necessary paths:
content: [
'./resources/**/*.blade.php',
'./resources/js/**/*.{vue,ts}',
],
Custom Vite Plugins
vite.config.ts:
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.ts'],
refresh: true,
}),
// Add custom plugins here
],
});
Middleware for Inertia
public function handle($request, Closure $next)
{
$response = $next($request);
if ($response->isInertia()) {
$response->withProps(['theme' => 'dark']);
}
return $response;
}
Custom Inertia Layouts
app/Http/Middleware/HandleInertiaRequests.php:
public function rootView(): string
{
return file_exists(resource_path('js/Pages/app.blade.php'))
? 'app'
: false;
}
Environment-Specific Config
.env variables to toggle features (e.g., debug mode):
// vite.config.ts
const isDebug = process.env.NODE_ENV === 'debug';
How can I help you explore Laravel packages today?