JavaScript dapps: User authentication with Blockstack

Take advantage of blockstack.js and blockchain to unlock decentralized authentication and authorization in 10 minutes

JavaScript dapps: User authentication with Blockstack
OlgaSalt / /getty

In the last post, I introduced Blockstack and discussed the two critical components for building decentralized apps, or dapps, on the platform. In this post, we’ll bootstrap our dapp for web development snippets with user authentication and authorization powered by blockstack.js, the JavaScript library for interacting with Blockstack.

When using blockstack.js for user login, you’ll need to present the user with a log-in button of sorts. When the user clicks the button, you call a library method that redirects them to a separate tab either driven by the Blockstack Browser app, if installed, or the web-based Blockstack log-in if the user doesn’t have the Blockstack Browser installed.

blockstack user authentication 1 IDG

The log-in screen we built into DotPodcast, a dapp for listening to podcasts.

blockstack user authentication 2 IDG

Blockstack’s user ID selection screen.

Once a user chooses their preferred ID or signs up for an account, they’ll be redirected to your app’s callback handler where you can get basic user information from the user and make other API calls on their behalf, such as saving or retrieving application information from their personal storage.

To continue reading this article register now

How to choose a low-code development platform