ALWAYS copy samchat, not TaskManager
TaskManager is broken. Samchat works. Start from samchat every time.
cp -r /path/to/samchat myapp
cd myapp# Update package name in metadata.json
sed -i '' 's/samchat/myapp/g' metadata.json
# Update Cargo.toml files
sed -i '' 's/samchat/myapp/g' Cargo.toml
sed -i '' 's/samchat/myapp/g' samchat/Cargo.toml
# Rename directory
mv samchat myapp- Your backend logic
- Keep the imports as-is (from hyperprocess_macro)
- Keep the #[hyperprocess] macro
- Modify the AppState struct for your needs
- Add your HTTP handlers with #[http]
{
"name": "myapp",
"publisher": "yourname"
}- Rename to match your app
- Update the API endpoints
- Keep the WebSocket structure intact
- Rename to match your app
- Update types to match your WIT output
CRITICAL: Keep this script tag:
<script src="/our.js"></script># First time - installs UI dependencies
kit bs --hyperapp
# Subsequent builds
kit b --hyperapp
# Start
kit sPartialEq error: Add #[derive(PartialEq)] to your structs
WIT type error: Return JSON strings instead of complex types
WebSocket not connecting: Check you have /our.js script tag
Import errors: Use hyperprocess_macro::* not separate crates
- Don't copy TaskManager
- Don't remove the
/our.jsscript - Don't use HashMap in WIT types
- Don't import serde separately
- Don't try WebSocket handlers (not implemented yet)
use hyperprocess_macro::*;
#[hyperprocess]
#[derive(Default, Serialize, Deserialize)]
pub struct AppState {
counter: u32,
}
#[http]
async fn increment(&mut self) -> u32 {
self.counter += 1;
self.counter
}
#[http]
async fn get_count(&self) -> u32 {
self.counter
}That's it. Start from samchat, modify incrementally, test often.