Create Mobile Dapp and Integrate Meta Account Authentication
Last updated
Was this helpful?
Last updated
Was this helpful?
This guide walks you through how to integrate Meta Account authentication into your mobile dapp using the @burnt-labs/abstraxion-react-native
package. With Meta Accounts, users can easily sign in using familiar login methods such as email or social accounts, eliminating the need for wallets or seed phrases. This simplifies the onboarding experience and lowers the barrier for mainstream adoption by providing a secure, traditional style authentication flow within a blockchain application.
Before getting started, ensure you have the following installed:
(v16 or later)
A code editor like
Meta Accounts are smart contract accounts created and managed by XION’s Abstraxion system. They abstract away traditional blockchain complexity and provide:
An oAuth2 style login mechanism (no wallet required) that allows for login via email, social accounts, passkeys and crypto wallets
Instant execution of pre-approved smart contract calls
Gasless transactions which allows for easy user onboarding
In your terminal, run the following commands which will create an Expo app with minimum required npm dependencies without configuring navigation due to the use of the blank
template:
Install the Abstraxion React Native package and storage utility:
Environment variables are key-value pairs configured outside your source code that allow your app to behave differently depending on the environment. The Expo CLI will automatically load environment variables with an EXPO_PUBLIC_
prefix from .env
files for use within your code.
To interact with your deployed contracts, you’ll set a few environment variables:
Create a .env.local
file in the root of your project and add the following where we've added an example contract with a treasury contract that's configured to work along with it:
EXPO_PUBLIC_CONTRACT_ADDRESS - The address of the smart contract your app will interact with.
EXPO_PUBLIC_TREASURY_CONTRACT_ADDRESS - The treasury contract associated with the above contract. It enables gasless transactions using fee grants and handles authorization permissions, allowing your dApp to execute transactions on behalf of the Meta Account holder—delivering a seamless user experience.
EXPO_PUBLIC_RPC_ENDPOINT - The RPC endpoint used to communicate with the XION blockchain.
EXPO_PUBLIC_REST_ENDPOINT - The REST endpoint for querying chain state via HTTP.
You can access these values in your code using process.env.
. For example:
The AbstraxionProvider
gives your app access to authentication and wallet state globally.
There are some important items here that have to be set for your app to run on either android and ios. Expo uses a scheme
to know which app to redirect back to and this must be unique to your app. Also for Android a package
name must be set and for iOS a bundleIdentifier
must be set.
Update your app.json
file with the following;
This wraps your entire app and ensures all child components can access authentication state and methods.
Once wrapped in the provider, you can use the useAbstraxion()
hook to access login methods, wallet state, and logout. Let's implement login and logout buttons to see authentication in action. Let's update App.tsx
with the following:
Here's what has been added:
Login Functionality
A “Login with Xion” button appears when the user is not logged in.
Utilizes the useAbstraxionSigningClient
hook to handle authentication.
Displays a loading state while connecting.
Logout Functionality
A “Logout” button appears when the user is logged in.
Uses the disconnect
method from the signing client to log out.
Displays a loading state while logging out.
User Information Display
The user’s address is shown once logged in.
Clean, modern UI with appropriate styling.
Error Handling
Proper error catching implemented for both login and logout operations.
Loading states prevent repeated clicks and improve UX.
Run your app.
npx expo run:android
Click the “Login with Xion” button.
Complete the Xion Abstraxion authentication flow.
Upon success, your address should appear along with a “Logout” button.
Click “Logout” to disconnect the session.
Now that your app is authenticated with Meta Accounts, you're ready to start interacting with the blockchain.
Depending on your goals, here are two paths you can take next:
This guide walks you through:
Using our one-click launcher to deploy a contract and frontend
Setting up a mobile app using a prebuilt template
Authenticating users and saving their data to the blockchain
It’s the fastest way to see the full dapp lifecycle in action.
This guide breaks down:
Smart contract integration using the Abstraxion
package
Transaction execution with Meta Accounts
Querying and updating on-chain data
Structuring your app for production use
It's ideal if you're building custom flows, want to extend contract functionality, or are preparing for a real-world deployment.
If you're looking to get something up and running quickly, follow our streamlined quick-start guide: .
If you want to understand how the mobile app works under the hood, explore this step-by-step tutorial: .