Local Development and E2E
Implementing Google, Internet Identity, or Passkeys requires some setup and doesn't always fit best in a local development environment or E2E test suite. For example, they take various steps to complete and therefore consume repetitive time.
Local dev identities skip all that.
They let you test authentication flows instantly - no setup, no external services, no waiting. Just one click with names like "alice" or "bob", and you're signed in.
For local development only - works exclusively on localhost and 127.0.0.1.
How It Works
- You optionally provide an identifier (e.g., "alice", "bob"). Default is "dev".
- A deterministic identity is generated on the client side from that identifier.
- The identifier is stored in IndexedDB and reused across sessions.
- You can switch between different dev identities easily.
Given the deterministic nature of these identities, as mentioned above, they cannot be used in production. That's why the library prevents any usage outside of localhost.
Sign-In
import { signIn } from "@junobuild/core";
// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for production
await signIn({
dev: {}
});
Options
| Option | Type | Default | Description |
|---|---|---|---|
identifier | string | "dev" | Unique identifier for this dev identity (max 32 characters) |
maxTimeToLiveInMilliseconds | number | 7 days | How long the session lasts in milliseconds |
Example:
// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for production
await signIn({
dev: {
identifier: "alice",
maxTimeToLiveInMilliseconds: 24 * 60 * 60 * 1000 // 1 day
}
});
Managing Identifiers
During development, you may want to see which identities you've used or clear them out.
Load
Retrieve all previously used dev identifiers, sorted by most recent first:
import { loadDevIdentifiers } from "@junobuild/ic-client/dev";
// ⚠️ DEV UTILITY - Not needed for production apps
const identifiers = await loadDevIdentifiers();
// [['alice', { createdAt: 1234567890, updatedAt: 1234567899 }], ...]
// You can also limit results
const recent = await loadDevIdentifiers({ limit: 5 });
Clear
Remove all stored dev identifiers from browser's IndexedDB:
import { clearDevIdentifiers } from "@junobuild/ic-client/dev";
// ⚠️ DEV UTILITY - Not needed for production apps
await clearDevIdentifiers();
Clearing identifiers only removes the usage history.
Recommendations
- ⚠️ Never use in production - automatically blocked on non-localhost domains
- Use different identifiers to test multi-user scenarios
- Switch to real providers (Google, Internet Identity, Passkeys) before deploying