Vue Mode provides RootAuth’s complete UI pages (login, registration, password reset) for quick integration. Only supports Vue 3 framework. The instance also includes all methods available in API mode (such as getToken, setLocale, etc.).
1. Preparation
Create an application in the RootAuth Console and copy the app_id (format: app_******).
2. Prerequisite
Please add the following configuration line to the .npmrc file in the project root directory:
@rootauth:registry=http://gitlab.standard-software.co/api/v4/projects/12421/packages/npm/
3. Install Dependencies
4. Create an Instance and Mount Routes
In the entry file main.js:
4.1 Complete Configuration Options
Vue Mode supports the following specific parameters:
5. View Merged Routes
6. Unmount the SDK
When authentication features are no longer needed, you can manually unmount to free memory:
client.unmount()
7. Google One Tap Login
You need to enable the enable_google_one_tap: true option when creating the instance.
const options: RootAuthClientConfig = {
app_id: 'app_******', // Required: app_id generated from the workspace
enable_google_one_tap: true // Set to true to enable One Tap login
}
const client = new RootAuthClient(options)
client?.googleOneTapLogin()
8. Other Methods
The client instance in Vue Mode also supports the following methods (usage is the same as in API mode):
| Method | Description |
|---|---|
client?.getAppConfig() |
Get application configuration |
client?.logout() |
Log out and clear the token |
client?.getToken() |
Get the current token |
client?.isAuthenticated() |
Check whether the user is logged in |
client?.setLocale('en-US') |
Switch language (zh-CN / en-US) |
