This example demonstrates how to use @session.js/client in web and @session.js/bun-network-remote to connect to Session network.
If you're not JavaScript developer looking for the way to use @session.js and instead looking for full-featured Session messenger web client, go to Session Web client by hloth.dev.
This repository is for Session clients developers, not Session users.
This example requires Bun.sh installed and basic knowledge of JavaScript, web technologies, React and Vite.
- Clone this repository, open
browser-simple
directory - Go to
client-side
andserver-side
directories and install dependencies usingbun install
in each of them - Start server by typing
PORT=8000 bun start
inserver-side
directory. If this port is occupied, you can change it, but beware that you will also need to change it in .env file inbrowser-simple
directory - Start client side by typing
bun run dev
inclient-side
directory, you should see something likeServer running at localhost:8000
. Open that url - Now you should see simple UI in your browser that lets you send messages to anyone in Session network from browser.
This example aims for simplicity, so you can start from scratch. As soon as you understand how proxying requests from browser to bun running in server-side
directory works, you can start building complex web client with any supported @session.js/client features such as files and images attachemnts, ONS resolving and messages polling.
Start by looking into client-side/src/app.tsx (also check out loader.tsx) and server-side/src/index.ts to get understanding of how separating client and server works.