Part 2 - Social login via Particle Auth

This 2-part tutorial will guide you through integrating with Bastion SDK in your Next.js app through Metamask and using social login via Particle Auth.

This is Part 2 of the tutorial.

Note: You can find the complete code for this app in this Github repo.

Prerequisites

  1. Node.js and npm installed

  2. Basic understanding of Next.js and React

  3. A Bastion account for API key

  4. A Particle Network account

  5. IMP - You should've finished Part 1 of this tutorial

What are Social Logins and MPC?

Social logins have become a popular way to authenticate users and manage private keys without passwords or secret recovery phrases, which are cumbersome. They allow you to leverage your existing accounts on platforms like Facebook, Google, Twitter, etc., to log into crypto apps and services.

MPC (multi-party computation) splits a private key into shares across multiple servers. This protects the key even if some servers are compromised.

Bastion SDK can be natively integrated with several MPC providers such as Particle Auth, web3 auth, amongst others. This part of the tutorial focuses on Particle Auth.

Step 1: Get Particle Network Credentials

  1. Go to the Particle Network Dashboard.

  2. Create a new project and navigate to the API section.

  3. Generate a new API key and note down the projectId, clientKey, and appId.

Step 2: Add Environment Variables

Add the additional required environment variable to .env.local file at the root of your Next.js project. It should now look like this

Replace the placeholder values with your actual Particle Network and Bastion API keys.

Step 3: Implement Particle Auth and Bastion in Next.js

Now, add the following code to the file pages/index.tsx

Step 4: Test Your Application

Run your Next.js app:

Navigate to http://localhost:3000 and click on the "Login with Particle Auth" button. Follow the Particle Auth login procedure, and you should see your Ethereum address displayed on the screen, indicating a successful login.

That's it! You've successfully integrated Particle Auth with the Bastion SDK in a Next.js application. You can now proceed to build more complex functionalities into your decentralized application.

Last updated