osgsm.io
HomeNotesAstro で開発中のサイトをスマホで動作確認する

Astro で開発中のサイトをスマホで動作確認する

Published Feb 20, 2025
Updated Mar 15, 2025

Astro では astro dev コマンドで開発サーバーを起動できるが、これに --host flag を渡すことで、同じネットワーク上にある他のデバイスで開発中のサイトにアクセスできる。

package.jsonscripts"dev": "astro dev" がある場合、次のように実行する。

pnpm dev --host

astro dev には、他にも次のような flags が用意されている。

Terminal
> astro "dev" "--help"
 
 
  astro dev [...flags]
 
   Flags 
                   --mode  Specify the mode of the project. Defaults to "development".
                   --port  Specify which port to run on. Defaults to 4321.
                   --host  Listen on all addresses, including LAN and public addresses.
  --host <custom-address>  Expose on a network IP address at <custom-address>
                   --open  Automatically open the app in the browser on server start
                  --force  Clear the content layer cache, forcing a full rebuild.
              --help (-h)  See all available flags.
 
Check https://docs.astro.build/en/reference/cli-reference/#astro-dev for more information.

参考