Get up and running with DRAV in minutes!
- Go 1.22 or later
- A terminal that supports ANSI escape sequences
- Windows Terminal (on Windows), iTerm2/Terminal.app (on macOS), or any modern Linux terminal
go get github.com/TIVerse/dravgo version
# Should output: go version go1.22 or laterLet's build a simple "Hello DRAV" application.
mkdir hello-drav
cd hello-drav
go mod init hello-dravgo get github.com/TIVerse/dravCreate main.go:
package main
import (
"context"
"log"
"github.com/TIVerse/drav/pkg/dravya"
"github.com/TIVerse/drav/pkg/maya"
)
func main() {
// Create the application
app := dravya.NewApp()
// Create a simple text view
root := maya.Text("Hello, DRAV! 🌊\n\nPress Ctrl+C to exit.")
// Set the root component
app.SetRoot(maya.Stateless(root))
// Run the application
if err := app.Run(context.Background()); err != nil {
log.Fatal(err)
}
}go run main.goYou should see "Hello, DRAV! 🌊" in your terminal!
Now let's build something more interesting with reactive state.
package main
import (
"context"
"fmt"
"log"
"github.com/TIVerse/drav/pkg/dravya"
"github.com/TIVerse/drav/pkg/maya"
"github.com/TIVerse/drav/pkg/prana"
)
type Counter struct {
count *prana.Observable[int]
}
func NewCounter() *Counter {
return &Counter{
count: prana.NewObservable(0),
}
}
func (c *Counter) Render(ctx maya.RenderContext) maya.View {
return maya.Column(
maya.Text("=== Reactive Counter ==="),
maya.Text(""),
maya.Text(fmt.Sprintf("Count: %d", c.count.Get())),
maya.Text(""),
maya.Text("Press [+] to increment"),
maya.Text("Press [-] to decrement"),
maya.Text("Press [r] to reset"),
maya.Text("Press [Ctrl+C] to exit"),
)
}
func (c *Counter) Increment() {
c.count.Update(func(n int) int { return n + 1 })
}
func (c *Counter) Decrement() {
c.count.Update(func(n int) int { return n - 1 })
}
func (c *Counter) Reset() {
c.count.Set(0)
}
func main() {
app := dravya.NewApp()
counter := NewCounter()
// Watch for changes (optional)
counter.count.Watch(func(old, new int) {
log.Printf("Count changed: %d → %d", old, new)
})
app.SetRoot(counter)
if err := app.Run(context.Background()); err != nil {
log.Fatal(err)
}
}app := dravya.NewApp(
dravya.WithLogLevel(slog.LevelInfo),
dravya.WithFPSCap(60),
dravya.WithMetrics(true),
)
// Set root component
app.SetRoot(myComponent)
// Run application
ctx := context.Background()
if err := app.Run(ctx); err != nil {
log.Fatal(err)
}Components implement the Component interface:
type Component interface {
Render(ctx RenderContext) View
}Create components as structs:
type MyComponent struct {
state *prana.Observable[string]
}
func (m *MyComponent) Render(ctx maya.RenderContext) maya.View {
return maya.Text(m.state.Get())
}Use observables for reactive values:
// Create observable
name := prana.NewObservable("Alice")
// Get value
fmt.Println(name.Get()) // "Alice"
// Set value (triggers watchers)
name.Set("Bob")
// Watch for changes
unwatch := name.Watch(func(old, new string) {
fmt.Printf("%s → %s\n", old, new)
})
defer unwatch()Compose UIs with layout primitives:
view := maya.Column(
maya.Text("Header"),
maya.Row(
maya.Text("Left"),
maya.Text("Right"),
),
maya.Text("Footer"),
)Now that you've built your first DRAV application, explore:
- Core Concepts - Deep dive into reactive state, events, and layouts
- Module Guides - Learn about each DRAV module
- Examples - Browse complete example applications
- API Reference - Complete API documentation
Make sure you're using Go 1.22 or later:
go versionCheck your terminal supports ANSI colors. On Windows, use Windows Terminal instead of cmd.exe.
Ensure dependencies are installed:
go mod tidy- Documentation: You're reading it!
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions
- Examples: Browse working code
Ready to build something amazing? Let's go! 🌊