Skip to main content
View Zag.js on Github
Join the Discord server


The Javascript SDK provides two methods for user authentication: loginWithEmail and login. Both of these authenticate the user, and return a refreshToken that can be used to silently authenticate a user without requiring them to login manually.

This refresh token is safe to store in your application client. If the autoLoginCredentials are provided to the SDK, then the user is automatically logged in by the SDK.

Silent Authentication

Here is an example of how to silently authenticate your user when your application has loaded.

import { MirrorWorld, ClusterEnvironment } from "@mirrorworld/web3.js" const refreshToken = "USER_REFRESH_TOKEN" const mirrorworld = new MirrorWorld({ apiKey: "SUPER_SECRET_API_KEY", env: ClusterEnvironment.mainnet, autoLoginCredentials: refreshToken }) mirrorworld.on('auth:refreshToken', async (refreshToken) => { await saveTheUsersNewRefreshToken(refreshToken) await mirrorworld.value.fetchUser() console.log(mirrorworld.user) // Logs user object. })

Edit this page on GitHub

On this page