Accessing AstroJS Site On Local Network IP

A small guide on how to access AstroJS site on local network IP. While this works by default on Next js, you need to add a small change to your package.json file to make it work on AstroJS.

Steps

Go to your package.json file and add --host to your dev script. It should look like this:

"scripts": {
    "dev": "astro dev --host",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  }

Now you can access your site on your local network IP. For example, if your local network IP is 192.168.1.1 you can access your site on http://192.168.1.1:4321/

Hope this helps!

Back To All Blogs