cretueusebiu/laravel-nuxt

A Laravel-Nuxt starter project template.


Keywords
laravel, SPA, vue, nuxt, server-rendering, ssr, universal
License
MIT

Documentation

Laravel-Nuxt

Build Status Total Downloads Latest Stable Version

A Laravel-Nuxt starter project template.

Features

  • Nuxt 2.8
  • Laravel 5.8
  • SPA or SSR
  • Socialite integration
  • VueI18n + ESlint + Bootstrap 4 + Font Awesome 5
  • Login, register, email verification and password reset

Installation

  • composer create-project --prefer-dist cretueusebiu/laravel-nuxt
  • Edit .env to set your database connection details and APP_URL (the url to your Laravel application)
  • (When installed via git clone or download, run php artisan key:generate and php artisan jwt:secret)
  • php artisan migrate
  • npm install

Usage

Development

npm run dev

You can access your application at http://localhost:3000.

Production

npm run build

You can access your application the url you set APP_URL to.

Enable SSR

  • Remove mode: 'spa' and '~plugins/nuxt-client-init' from client/nuxt.config.js
  • Edit .env to set APP_URL=http://api.example.com and CLIENT_URL=http://example.com
  • Run npm run build and npm run start

Nginx Proxy

For Nginx you can add a proxy using the follwing location block:

server {
    location / {
        proxy_pass http://http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Process Manager

In production you need a process manager to keep the Node server alive forever:

# install pm2 process manager
npm install -g pm2

# startup script
pm2 startup

# start process
pm2 start npm --name "laravel-nuxt" -- run start

# save process list
pm2 save

# list all processes
pm2 l

After each deploy you'll need to restart the process:

pm2 restart laravel-nuxt 

Make sure to read the Nuxt docs.

Notes

  • This project uses router-module, so you have to add the routes manually in client/router.js.
  • If you want to separate this in two projects (client and server api), move package.json into client/ and remove config path option from the scripts section. Also make sure to add the env variables in client/.env.

Changelog

Please see CHANGELOG for more information what has changed recently.