templates/chat-react-ts/README.md
This is a simple chat application that demonstrates how to use SpacetimeDB with TypeScript and React. The chat application is a simple chat room where users can send messages to each other. The chat application uses SpacetimeDB to store the chat messages.
It is based directly on the plain React + TypeScript + Vite template. You can follow the quickstart guide for how creating this project from scratch at SpacetimeDB TypeScript Quickstart.
You can follow the instructions for creating your own SpacetimeDB module here: SpacetimeDB Rust Module Quickstart. Place the module in the quickstart-chat/server directory for compability with this project.
In order to run this example, you need to:
pnpm build in the root directory (spacetimedb-typescriptsdk)pnpm install in this directorypnpm build in this directorypnpm dev in this directory to run the exampleBelow is copied from the original template README:
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
parserOptions property like this:export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
});
tseslint.configs.recommended to tseslint.configs.recommendedTypeChecked or tseslint.configs.strictTypeChecked...tseslint.configs.stylisticTypeChecked// eslint.config.js
import react from 'eslint-plugin-react';
export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
});