Vue Get Ip Address
In this tutorial, we provide two examples to obtain the client's IP address using Vue.js. In the first example, we utilize the Options API, and in the second example, we employ the Composition API. In both examples, we utilize an external API, namely, ipify to get ip address.
written
reviewed
updated
Thanks for your feedback!
Your contributions will help us to improve service.
How to get client IP address in Vue Js?
In the code below, we utilize Vue js options API to retrieve the IP address of the local machine. We use the Axios library to make an HTTP GET request to the ipify API endpoint. In the response, we obtain the user's IP address
Output of above example
In this example, we used the Composition API of Vue.js, i.e., Vue 3, to achieve the same results as above.
Vue 3 Get Local ip Address Client Side
Ad