Variable: ConnectionsContext

typescript
1
const ConnectionsContext: Context<undefined | { connections: DIDPair[]; deleteConnection: (connection) => Promise<void>; load: () => Promise<void>; }>

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

React context for DID connection management.

Provides functionality for managing established DID connections (relationships between DIDs) including viewing and deleting connections. Essential for managing the network of trusted relationships in an identity system.

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
30
31
32
33
34
35
import { ConnectionsContext } from '@trust0/identus-react/context';
import { useContext } from 'react';
function ConnectionManager() {
const context = useContext(ConnectionsContext);
if (!context) {
throw new Error('ConnectionManager must be used within ConnectionsProvider');
}
const { connections, deleteConnection } = context;
const removeConnection = async (connection: SDK.Domain.DIDPair) => {
if (confirm('Delete this connection?')) {
await deleteConnection(connection);
}
};
return (
<div>
<h3>My Connections ({connections.length})</h3>
{connections.map((connection, index) => (
<div key={index}>
<h4>Connection {index + 1}</h4>
<p>Host: {connection.host.toString()}</p>
<p>Receiver: {connection.receiver.toString()}</p>
<button onClick={() => removeConnection(connection)}>
Delete
</button>
</div>
))}
</div>
);
}