Vue Guide
Connection State
Monitor the Convex realtime connection and react to disconnects in your UI.
Use useConvexConnectionState when you want to show connectivity status or pause parts of the UI while the realtime client is offline.
Read the connection state
src/components/ConnectionBanner.vue
<script setup lang="ts">
import { useConvexConnectionState } from 'vue-convex'
const { state, isConnected } = useConvexConnectionState()
</script>
<template>
<div v-if="!isConnected" class="banner">
Reconnecting...
</div>
</template>
What the composable gives you
stateexposes the underlying ConvexConnectionStateobject, ornullwhen no realtime client is connectedisConnectedis a convenience computed that maps tostate.value?.isWebSocketConnected
Useful fields on state.value include:
isWebSocketConnectedhasInflightRequestshasEverConnectedconnectionCountinflightMutations
Verify the result
The connection-state wiring is working when:
isConnectedreflects the current socket state- disconnecting the client updates your UI
- reconnecting clears the offline indicator
Next steps
- Read Controller if your app connects and disconnects explicitly
- Read
useConvexConnectionStatefor the exact return type