DEV Community

loading...

Adding a link to your console.log in Javascript

Maxwell Adapoe
・1 min read

Many of us as JS devs have come across hyperlinks in the output of console.log which when clicked navigates to a page or url (usually in your terminal when running npm run start or in your browser console when debugging your app written in React or Vue).

Sample console log

Well creating this is rather simple:

console.log('http://mysite.com');
console.log('www.mysite.com');
Enter fullscreen mode Exit fullscreen mode

all you need to do is to have a valid link in the url and thats it. It works.

Below are some options that will not work:

console.log('example.com');
console.log('<a href="http://www.example.com">Link</a>');
Enter fullscreen mode Exit fullscreen mode

Thanks for reading.

Discussion (2)