Variable: PeerDIDContext

typescript
1
const PeerDIDContext: Context<undefined | { create: () => Promise<DID>; peerDID: null | DID; }>

Defined in: packages/identus-react/src/context/index.ts:107

React context for managing Peer DID operations and state.

Peer DIDs are ephemeral, off-ledger identifiers used for direct peer-to-peer communication. They can be created quickly without blockchain interaction and are ideal for secure messaging between parties.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { PeerDIDContext } from '@trust0/identus-react/context';
import { useContext } from 'react';
function PeerDIDManager() {
const context = useContext(PeerDIDContext);
if (!context) {
throw new Error('PeerDIDManager must be used within PeerDIDProvider');
}
const { peerDID, create } = context;
const handleCreatePeerDID = async () => {
await create();
};
return (
<div>
{peerDID ? (
<div>
<p>Peer DID: {peerDID.toString()}</p>
<p>Ready for secure messaging</p>
</div>
) : (
<button onClick={handleCreatePeerDID}>Create Peer DID</button>
)}
</div>
);
}