Authentication library for Internet Computer web apps
npm install @icp-sdk/auth

Authentication library for Internet Computer web apps.
> Still using @dfinity/auth-client? Migrate to @icp-sdk/auth!
---
You can install the @icp-sdk/auth package with your package manager of choice:
``shell`
npm install @icp-sdk/auth
`shell`
pnpm add @icp-sdk/auth
`shell`
yarn add @icp-sdk/auth
> Note: this package is only meant to be used in browser environments.
Here's a simple example of how to use the @icp-sdk/auth package to authenticate a user with Internet Identity on an Internet Computer web app:
`typescript
import { AuthClient } from '@icp-sdk/auth/client';
const identityProvider = 'https://id.ai/';
const authClient = await AuthClient.create();
const identity = authClient.getIdentity(); // At this point, you'll get a Principal.anonymous()
async function onSuccess() {
console.log('Login successful');
const identity = authClient.getIdentity(); // At this point, you'll get an authenticated identity
console.log(authClient.isAuthenticated()); // true
}
await authClient.login({
identityProvider,
onSuccess,
});
// later in your app
await authClient.logout();
``
Additional documentation can be found here.
Contributions are welcome! Please see the contribution guide for more information.
This project is licensed under the Apache-2.0 license.