Install WSX in your project
npm install @wsx-sh/core @wsx-sh/express
npm install @wsx-sh/core @wsx-sh/hono
npm install @wsx-sh/core
<script src="/path/to/wsx.js"></script>
cp node_modules/@wsx-sh/client/wsx.js public/wsx.js
import { WSXServer, WSXRequest, WSXResponse } from "@wsx-sh/core"; import { createExpressWSXServer } from "@wsx-sh/express"; const wsx = createExpressWSXServer(); wsx.on("my-handler", async (request: WSXRequest, connection) => { const response: WSXResponse = { id: request.id, target: request.target, html: "<div>Hello TypeScript!</div>", }; return response; });
import { createExpressWSXServer } from "@wsx-sh/express"; import express from "express"; const wsx = createExpressWSXServer(); const app = wsx.getApp(); // Your Express middleware and routes app.use(express.static("public")); // WSX handlers wsx.on("my-handler", async (request, connection) => { return { id: request.id, target: request.target, html: "<div>Hello from Express!</div>", }; }); const server = app.listen(3000, () => { console.log("Server running on port 3000"); });
import { createHonoWSXServer } from "@wsx-sh/hono"; const wsx = createHonoWSXServer(); const app = wsx.getApp(); // Your Hono routes app.get("/", (c) => c.html("<h1>Hello Hono!</h1>")); // WSX handlers wsx.on("my-handler", async (request, connection) => { return { id: request.id, target: request.target, html: "<div>Hello from Hono!</div>", }; }); export default { fetch: app.fetch, };
import { createHonoWSXServer } from "@wsx-sh/hono"; const wsx = createHonoWSXServer(); const app = wsx.getApp(); // Your worker logic wsx.on("worker-handler", async (request, connection) => { return { id: request.id, target: request.target, html: "<div>Hello from Cloudflare Workers!</div>", }; }); export default { fetch: app.fetch, };
import { createExpressWSXServer } from "@wsx-sh/express"; const wsx = createExpressWSXServer(); console.log("WSX server created successfully");
<script src="/wsx.js"></script> <script> console.log("WSX client loaded:", typeof WSX !== "undefined"); </script>
Module not found errors
@wsx-sh/core
@wsx-sh/express
@wsx-sh/hono
TypeScript compilation errors
Client script not loading
WebSocket connection issues
<div wx-config='{"url": "ws://localhost:3000/ws", "debug": true}'> <!-- Your content --> </div>
<div wx-config='{"url": "wss://your-domain.com/ws", "debug": false}'> <!-- Your content --> </div>