Book a Free Call

Nuxt view localhost on device over WiFi (IP)



Here’s a quick and very handy one:

Say you are running your Nuxt site as normal on localhost:3000, and you want to run it off a tablet or phone or something over the same network:

Go to package.json

{
  "name": "YOURPROJECT",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
      "dev:host": "nuxt --hostname 0.0.0.0 --port 8000"    <<<< add this bad boy, (remember no comma if it's the last item)
  },
  "dependencies": {
    "core-js": "^3.15.1",
    "nuxt": "^2.15.7",
    "particles.vue": "^2.19.0",
    "sass": "^1.41.1",
    "sass-loader": "10",
    "vue": "2",
    "vue-scroll-reveal": "^1.0.11"
  },
  "devDependencies": {
    "@nuxtjs/google-fonts": "^1.3.0"
  }
}

This will give you your site at your NORMAL IP address (go to cmd and type ipconfig to find out what this is if you don’t already know it) and a port of 8000. So if you grab your phone now, you will see your site at 192.whatever.your.ipnumber:8000

Hope that helps someone!

Need rapid website development:

For smaller projects at high speed

Get an instant quote
  • WordPress Super-admin hack

    Read More
  • Add content or ACF field under thumbnail/image gallery in Woocommerce

    Read More
  • Nuxt view localhost on device over WiFi (IP)

    Read More
  • AIO WP Migration: Import stuck on “done preparing blogs” or “done preparing plugins”

    Read More
  • Nuxt Ecommerce (Snipcart/Stripe)

    Read More

Tags


Categories

Charlie's Cottage, Carrigrohane, Co. Cork, T12 WY9H

(085) 7686677