Skip to content
alzafchat / Developers

Documentation / Integrations

Laravel Blade

Use the browser widget in server-rendered pages.

Integration guide

The example installs the Composer package inside Laravel and serves a Blade page using the same browser widget as plain HTML. This verifies an embedded Laravel host UI; it does not introduce a second login system for real host projects.

Run the repository's local setup/build and LAN startup commands from local setup. Open http://localhost:8000/demo or your LAN host on port8000. Select a seeded customer, seller, staff member or admin and press Sign in. Use a second browser tab with a different role to reply. The customer can start a conversation; the matching seller/team can reply; the service admin joins before replying. Other stores and services cannot access that conversation.

/demo/widget.js serves packages/html-widget/dist/browser/chat-widget-0.1.13.global.js. It returns 503 with an instruction to run npm run build:packages from the repository root when the bundle is absent. Both /demo and this script route return 404 in production. The demo login is local/testing only; never expose it as production authentication.

The Blade page calls AlzafChat.mount({target:'#chat',apiBaseUrl:location.origin+'/api/chat',token:userToken,reverb:{key:'local-chat',host:location.hostname,port:8085,scheme:'http'}}) with public key, port and scheme rendered from the backend Reverb configuration. The bundle has no npm requirement for the consuming HTML page. The returned destroy() is called on sign-out, identity switch and page exit to release listeners/connections. Tokens stay in page memory; sign-out cleans up the UI but does not revoke the example's expiring token on the server.

For an existing Laravel project, follow Composer integration, load your pinned browser bundle from a trusted static location, and obtain the signed-in person's token from your own secure authentication flow. Configure actual API and broadcast auth locations, origin allowlists and HTTPS/WSS. Cookie/session host auth requires lifecycle/CSRF verification and is not verified by this bearer demonstration. Branding/customization follows the widget guide; do not put a privileged API key in Blade output.

Verification: backend feature tests check Blade demo route rendering and production gating. The parent project performs browser chat smoke verification against the built widget; consult project status for actual browser evidence.