DEV Community

Cover image for Access Localhost from Smartphone with help of VS Code and Live Server
B Kanhu Charan
B Kanhu Charan

Posted on • Updated on

Access Localhost from Smartphone with help of VS Code and Live Server

Responsive Web design, well I know the developer console is a greater tool for debugging. and it gives you an option to check the responsiveness of your webpage. but checking it on a real device is always better.
So how to do it without too much hassle? The simple answer is with help of VS Code and Extensions called Live Server.

Before proceeding make sure your laptop and mobile device are connected to the same wifi.

For this, you need to install VS Code from here. And Live Server Extensions by Ritwick Dey from here.

After installing open your project folder on VS Code. You can do it by "drag-and-drop" or by navigating to "File > Open Folder".

Then open index.html and right-click on Editor, from the "Explorer Window" choose "Open with Live Server".

vs-code-open-with-live-server.png

Remember the port, on which the live server is running.

live-server-ip-address.png

Now open "Command Prompt" on windows and type ipconfig hit Enter. Check the IP Address.

Now open your favorite browser on your smartphone and on the address bar enter the IP Address of your Computer and port of the local server. after that file name. like http://ip_address:port/filename for example, mine would be: http://196.168.43.14:5500/index.html

live-server-mobile-preview.jpeg

Top comments (4)

Collapse
 
8koi profile image
Hachikoi

I want this but with something like React/Next, any idea? not even sure how to search for it :c

Collapse
 
bkanhu profile image
B Kanhu Charan

Hey, this method is also applicable to React/Next JS. You won't require Live server in this case, as you can simply use npm run dev. To access the application from another device, visit http://ip_address:port in your web browser.

Collapse
 
faridulhassan profile image
Faridul Hassan

It works.
Thank you.

Collapse
 
gracechinelo profile image
Gracechinelo

Thank you so much, I got it up and running