# `PhoenixKit.Modules.Sync.Web.SocketPlug`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.62/lib/modules/sync/web/socket_plug.ex#L1)

Plug for handling DB Sync WebSocket connections.

This plug handles the HTTP upgrade to WebSocket and validates
the connection code or auth token before handing off to SyncWebsock.

## Authentication Methods

Supports two authentication methods:

1. **Session Code** (ephemeral) - For manual one-time transfers
   - Query param: `?code=ABC12345`
   - Session is tied to LiveView process

2. **Connection Token** (permanent) - For persistent connections
   - Query param: `?token=xyz123...`
   - Validated against database, subject to access controls

## Usage

In your endpoint:

    plug PhoenixKit.Modules.Sync.Web.SocketPlug

Or mount at a specific path in router (done automatically by phoenix_kit_socket macro).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
