Anon Chat is a simple anonymous chat application with:
- A Rust backend using Tokio and Warp for a WebSocket chat server
- A React Native mobile app built with Expo Router as the client
This repository contains both parts:
- Backend server:
be - Mobile client:
mobile
Tip: On Git hosting providers that support it, the video link can usually be played in the browser.
-
Backend (Rust)
- Located in
be - Uses:
tokioas the async runtimewarpas the HTTP/WebSocket server frameworkserde/serde_jsonfor JSON serializationuuidfor identifiers
- Exposes a WebSocket endpoint:
ws://<HOST>:3030/ws?username=<name>
- Manages connected users in memory and broadcasts messages to everyone.
- Located in
-
Mobile (Expo / React Native)
- Located in
mobile - Built with Expo Router (file-based routing)
- Connects to the backend WebSocket endpoint and renders a simple chat UI
- Anonymous usernames are generated on the client
- Located in
Requirements:
- Rust toolchain (cargo)
Steps:
cd be
cargo runBy default, the server:
- Listens on
127.0.0.1:3030 - Exposes WebSocket at
ws://127.0.0.1:3030/ws?username=<name>
If you run the mobile app on a device or simulator, make sure the server’s host/IP in the mobile app matches where the backend is actually reachable from that device (for example, your machine’s LAN IP instead of 127.0.0.1).
Requirements:
- Node.js and npm
- Expo CLI (via
npx expoor globally)
Install dependencies:
cd mobile
npm installStart the Expo development server:
cd mobile
npx expo startYou can then open the app in:
- iOS simulator
- Android emulator
- Physical device via Expo Go
The mobile app connects to the backend using a constant in the chat screen:
- File:
mobile/app/chat/index.tsx - Constant:
const SERVER_URL = 'ws://10.164.186.97:3030';Change SERVER_URL to match your backend:
- For iOS simulator: often
ws://127.0.0.1:3030orws://localhost:3030 - For physical devices: use your computer’s LAN IP, e.g.
ws://192.168.x.x:3030
- ESLint is configured via
eslint.config.js. - Prettier is configured for auto-formatting:
- Config:
mobile/.prettierrc.json - Ignore:
mobile/.prettierignore
- Config:
Useful scripts (from mobile/package.json):
cd mobile
# Lint
npm run lint
# Format code with Prettier
npm run format
# Check formatting (CI-friendly)
npm run format:checkVS Code settings under mobile/.vscode enable Prettier as the default formatter and format-on-save for JS/TS/TSX.
You can use standard Rust tooling:
cd be
# Build
cargo build
# Run
cargo runAdd cargo fmt / cargo clippy as needed if you want stricter formatting and linting for the backend.
anon_chat/
├─ be/ # Rust WebSocket backend (Tokio + Warp)
│ ├─ src/
│ └─ Cargo.toml
├─ mobile/ # Expo React Native mobile app
│ ├─ app/ # Expo Router routes
│ ├─ components/ # Reusable UI components
│ ├─ assets/ # Images and other assets
│ └─ package.json
└─ readme-assets/ # Assets used in this README
├─ screenshot.png
└─ video.mov
