laravel-nuxt

Build a SPA with Laravel and Nuxt
4,089 146
Install
npm install laravel-nuxt
Latest Version:2.0.2
Vue:2
License:MIT
Last Updated:Oct 13, 2020
Links: GitHub  ·  npm
Maintainer: skyrpex

Laravel Nuxt JS

TravisCI Build status

This package allows you to build a SPA with Laravel and Nuxt.

Installation

npm install laravel-nuxt

Attention! You must install the laravel-nuxt PHP package first.

Getting Started

Optionally, you will want to get rid of the default Laravel scaffolding.

Add a script to your package.json like this:

{
    "scripts": {
        "start": "laravel-nuxt"
    },
}

Wrap you nuxt.config.js's export with laravelNuxt:

const laravelNuxt = require("laravel-nuxt");

module.exports = laravelNuxt({
  // Your Nuxt options here...
  modules: [],
  plugins: [],

  // Options such as mode, srcDir and generate.dir are already handled for you.
});

Populate resources/nuxt/pages/index.vue inside your project:

<template>
  <h1>Hello {{ name }}!</h1>
</template>

<script>
export default {
  data: () => {
    return { name: 'world' };
  },
};
</script>

And then run:

npm start

Go to http://localhost:8000.

Commands

Development

laravel-nuxt dev

Starts both Nuxt and Laravel artisan servers in development mode (hot-module reloading, error reporting, etc).

Production

laravel-nuxt build

Compiles the application for production deployment.

This command will output the compiled assets in public/_nuxt.

Analysis

laravel-nuxt build -a

Launch webpack-bundle-analyzer to optimize your bundles.

Other

Getting rid of the default Laravel scaffolding

The default Laravel installation comes with some frontend files which are not needed anymore.

You can remove the following files and directories:

  • resources/assets/
  • package.json
  • package-lock.json
  • webpack.mix.js

Related Packages

nuxt-laravel

Nuxt cli extension for use with laravel as backend

5,317 101
@awes-io/nuxt-laravel

AwesCode UI module for connection with Laravel backend

7,075 9
nuxt-outfit

Outfit - Connection Laravel and Nuxt

2,727 0
nuxt-laravel-precognition

Nuxt module to work with Laravel Precognition and $fetch

2,009 10
@drozd/nuxt-performance

Nuxt high load functional

2,949 14

Version History

Version Released Vue License
2.0.2 ^2.0 MIT
2.0.1 ^2.0 MIT
2.0.0 ^2.0 MIT
1.5.1 ^2.0 MIT
1.5.0 ^2.0 MIT
Pre-releases (1)
Version Released Vue License
2.0.0-1 ^2.0 MIT