This guide explains how to set up and use Internet Identity canister on your local DFX network.
Internet Identity is a decentralized identity provider for the Internet Computer that allows users to authenticate with dApps using WebAuthn-compatible devices (like biometric authentication on your phone or computer).
- DFX installed (version 0.15.0 or later)
- A modern web browser with WebAuthn support
- A WebAuthn-compatible device (fingerprint reader, face ID, etc.)
-
Run the deployment script:
./deploy-internet-identity.sh
-
Access Internet Identity:
- Open your browser and navigate to the URL provided by the script
- It will look like:
http://localhost:4943/?canisterId=<canister-id>
-
Create your first identity:
- Click "Create Internet Identity"
- Follow the prompts to set up your device
- Note down your identity anchor number
If you prefer to set up manually:
-
Start the local network:
dfx start --background --clean
-
Deploy Internet Identity:
dfx deploy internet_identity
-
Get the canister ID:
dfx canister id internet_identity
-
Install the Internet Identity library:
npm install @dfinity/auth-client @dfinity/identity
-
Initialize the auth client:
import { AuthClient } from '@dfinity/auth-client'; import { InternetIdentity } from '@dfinity/auth-client/lib/cjs/identity/internet-identity'; const authClient = await AuthClient.create();
-
Configure Internet Identity:
const internetIdentity = new InternetIdentity({ identityProvider: 'http://localhost:4943/?canisterId=<your-canister-id>' });
-
Add Internet Identity dependency to your
mops.toml:[dependencies] internet_identity = "0.1.0"
-
Import and use in your Motoko code:
import InternetIdentity "mo:internet_identity"; // Your canister logic here
The deployment script creates a .env.local file with:
INTERNET_IDENTITY_CANISTER_ID: The canister ID of your local Internet IdentityINTERNET_IDENTITY_URL: The URL to access Internet Identity
-
"DFX is not installed"
- Install DFX:
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
- Install DFX:
-
WebAuthn not working
- Ensure you're using HTTPS or localhost
- Check that your device supports WebAuthn
- Try a different browser
-
Canister deployment fails
- Check that the local network is running:
dfx ping - Restart the network:
dfx stop && dfx start --background --clean
- Check that the local network is running:
To reset your local Internet Identity:
dfx stop
dfx start --background --clean
dfx deploy internet_identity- The local Internet Identity is for development only
- Never use local canister IDs in production
- Always use the official Internet Identity canister on mainnet for production applications
If you encounter issues:
- Check the DFX logs:
dfx logs internet_identity - Verify your DFX version:
dfx --version - Ensure your browser supports WebAuthn