Guest Sessions
Guest sessions allow users to interact with your dApp before signing up. A temporary Canton party is allocated for the guest, and when they register, their guest wallet merges into their real account.
How It Works
- Guest visits your dApp and clicks "Continue as Guest"
- PartyLayer creates a temporary session with a Canton party
- Guest can submit transactions, view contracts, and interact normally
- When the guest signs up, their data is automatically converted to a full account
Configuration
Enable guest sessions in your SDK config:
const pl = new PartyLayerEnterprise({
appId: 'app_xxx',
apiKey: 'pk_live_xxx',
guest: {
enabled: true,
sessionTtlMinutes: 1440, // 24 hours (default)
autoConvertOnLogin: true, // auto-merge on signup (default)
},
});React Integration
Show Guest Option in LoginButton
import { LoginButton } from '@partylayer/enterprise-react';
function App() {
return (
<LoginButton
providers={['auth0', 'passkey']}
showGuestOption
onGuestStart={() => console.log('Guest session started')}
/>
);
}useGuest Hook
import { useGuest } from '@partylayer/enterprise-react';
function GuestBanner() {
const { session, isActive, createSession, convert, expireSession } = useGuest();
if (!isActive) return null;
return (
<div>
<p>You are browsing as a guest. Sign up to save your progress.</p>
<button onClick={expireSession}>Leave Guest Mode</button>
</div>
);
}SDK Methods
// Create a guest session
const session = await pl.guest.create();
// Check if guest session is active
if (pl.guest.isActive()) {
// Guest is active
}
// Convert guest to full user
const result = await pl.guest.convert({
email: 'alice@example.com',
name: 'Alice',
auth0Id: 'auth0|abc123',
});
// Expire guest session
await pl.guest.expire();Auto-Convert on Login
When autoConvertOnLogin is enabled (default), the guest session is automatically converted when the user logs in through any auth provider. The guest's Canton party and any associated data are merged into the new user account.
Events
| Event | Description |
|---|---|
guest:created | Guest session was created |
guest:converted | Guest was converted to a full user |
guest:expired | Guest session expired or was manually ended |
REST API
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/guests | Create guest session |
| GET | /api/v1/guests/:id | Get guest session |
| POST | /api/v1/guests/:id/convert | Convert to full user |
| DELETE | /api/v1/guests/:id | Expire session |
| POST | /api/v1/guests/cleanup | Bulk expire old sessions |