It's actually pretty simple. For logging in, you get the credentials from the user on the page, and store them in variables. Then, you make a request to your server, and that server sends back a JWT (JSON Web Token) if the credentials were correct. You can use that JWT for further requests needing authentication so you don't need to provide username and password for every request.
Local storage and cookies basically do the same thing, they store data on the client. You use those data stores to save your token, so you don't need to get a new JWT every time you open the site.
As you've added VueJS to your tags, here's a guide for that framework (you'll probably need to scroll down a bit to get to the authentication parts):
auth0.com/blog/build-an-app-with-vuejs
Have fun!