Quikko’s WebSocket hub broadcasts every click event to connected clients in real time. The Next.js dashboard opens a persistent WebSocket connection on load and updates charts and counters the instant a redirect fires — no polling interval, no page refresh. The same connection carries events for all of a user’s URLs simultaneously, making the dashboard feel live regardless of how many links you’re tracking.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Andr21Da16/Quikko/llms.txt
Use this file to discover all available pages before exploring further.
How It Works
When a visitor follows a short link, the redirect handler resolves the destination and immediately fires an async recording call. The analytics service writes the event to InfluxDB and callsPublishClickEvent on the hub. The hub fans the event out to two rooms: user:{ownerID} (the URL owner’s personal room) and url:{shortCode} (the per-URL room). Any client subscribed to either room receives the message within milliseconds.
Connecting
token query parameter. This is intentional — browser WebSocket APIs do not allow custom headers during the HTTP upgrade handshake, so Authorization: Bearer cannot be used here. The token is validated before the upgrade completes; an invalid or expired token receives a standard 401 HTTP response and the connection is never upgraded.
Automatic User Room Subscription
Immediately after a successful upgrade, the server subscribes the client touser:{userID} — derived automatically from the JWT claims. This means you start receiving live click events for all your short URLs with zero additional messages. No subscribe call is needed for the general dashboard view.
Optional Per-URL Subscription
For URL detail views, you can subscribe to a specific URL’s channel to receive a focused stream:shortCode belongs to the authenticated user before adding the client to the url:{shortCode} room. If the URL is not yours (or does not exist), the server sends back an error message and leaves the connection open — the connection is never dropped over a failed subscription.
To stop receiving events for a URL:
Message Types
| Type | Direction | Purpose |
|---|---|---|
subscribe | client → server | Subscribe to a per-URL channel |
unsubscribe | client → server | Unsubscribe from a per-URL channel |
click_event | server → client | A redirect just fired on one of your URLs |
error | server → client | Protocol error (e.g. subscribing to another user’s URL) |
The click_event Payload
Every time a redirect fires for a URL you are subscribed to, the server pushes:
| Field | Description |
|---|---|
shortCode | The short code that was clicked |
country | ISO 3166-1 alpha-2 country code of the visitor |
deviceType | desktop, mobile, or tablet |
browser | Browser family (Chrome, Firefox, Safari, Edge, …) |
timestamp | UTC time of the redirect |
Non-Blocking Broadcast
The hub’sBroadcast method uses a non-blocking select/default when writing to each client’s send channel. If a client’s buffer is full — for example, because it has stalled or is processing slowly — that specific message is dropped for that client only. All other clients in the room receive the event normally. The hub never blocks waiting on a slow consumer.