1
Setup Better Auth with Next.js
First, follow the complete Better Auth Next.js Quickstart Guide to set up your Better Auth project and Next.js integration.
Then proceed to Better Auth Basic Usage to learn how to create your login and sign up pages.This will guide you through:
- Creating Better Auth Tables and Schemas
- Setting up your Next.js app with Better Auth
- Configuring environment variables
- Creating
auth.ts, mounting the handler and client instance - Creating login and sign up pages ready to receive new users 🎉
2
Setup the Better Auth JWT Plugin
- In your
auth.tsfile add the following configuration:
- Migrate or generate your database:
- Migrate
- Generate
npx @better-auth/cli migrateNote: Before proceeding, check the Better Auth CLI Docs to determine which CLI commands and setup fit your specific use case best.
3
Create an auth-client.ts
You need to create an
auth-client.ts - required for client side JWT functionality4
Create API route handler
Create a newroute.tsfile under/api/[...all]/route.tswith the following content.
5
Create a use-better-auth.ts for getting JWTs and Deploy your app
- Deploy your app, then add your deployed application URL to your environment variables:
6
Install the Chipi SDK
First, install the required packages:
7
Setup the Chipi SDK Provider
8
Add your JWKs Endpoint Url to Chipi 🕺 !
Visit the dashboard JWKS and JWT configuration, select
Better Auth as your auth provider and paste your JWKS Endpoint URL.9
Using Better Auth with Chipi hooks 🕺 !
Below you will see a simple example of how you can get and pass your tokens to the different Chipi hooks:
10
Celebrate & Learn More!
That’s it! You should now have an initial working version of Chipi Pay integrated into your application. You can now start implementing various features like:
- Wallet Creations
- Sending tokens
- Signing transactions
- and more!
