Manager API
The Wails v3 Manager API provides an organised and discoverable way to access application functionality through focused manager structs grouped under public fields on *application.App. Wails 3 is a clean break from v2 — there is no per-call wrapper layer to maintain compatibility with the old app.NewWebviewWindow(...)-style API, so the managers below are the way to drive the app.
Overview
Section titled “Overview”The Manager API organises application functionality into twelve focused areas (one logger plus eleven managers):
app.Window- Window creation, management, and callbacksapp.ContextMenu- Context menu registration and managementapp.KeyBinding- Global key binding managementapp.Browser- Browser integration (opening URLs and files)app.Env- Environment information and system stateapp.Dialog- File and message dialog operationsapp.Event- Custom event handling and application eventsapp.Menu- Application menu managementapp.Screen- Screen management and coordinate transformationsapp.Clipboard- Clipboard text operationsapp.SystemTray- System tray icon creation and managementapp.Autostart- Register the application to launch at user login
Benefits
Section titled “Benefits”- Better discoverability - IDE autocomplete shows organized API surface
- Improved code organization - Related methods grouped together
- Enhanced maintainability - Separation of concerns across managers
- Future extensibility - Easier to add new features to specific areas
The Manager API provides organized access to all application functionality:
// Events and custom event handlingapp.Event.Emit("custom", data)app.Event.On("custom", func(e *CustomEvent) { ... })
// Window managementwindow, _ := app.Window.GetByName("main")app.Window.OnCreate(func(window Window) { ... })
// Browser integrationapp.Browser.OpenURL("https://wails.io")
// Menu managementmenu := app.Menu.New()app.Menu.Set(menu)
// System traysystray := app.SystemTray.New()Manager Reference
Section titled “Manager Reference”Window Manager
Section titled “Window Manager”Manages window creation, retrieval, and lifecycle callbacks.
// Create windowswindow := app.Window.New()window := app.Window.NewWithOptions(options)current := app.Window.Current()
// Find windowswindow, exists := app.Window.GetByName("main")windows := app.Window.GetAll()
// Window callbacksapp.Window.OnCreate(func(window Window) { // Handle window creation})Event Manager
Section titled “Event Manager”Handles custom events and application event listening.
// Custom eventsapp.Event.Emit("userAction", data)cancelFunc := app.Event.On("userAction", func(e *CustomEvent) { // Handle event})app.Event.Off("userAction")app.Event.Reset() // Remove all listeners
// Application eventsapp.Event.OnApplicationEvent(events.Common.ThemeChanged, func(e *ApplicationEvent) { // Handle system theme change})Browser Manager
Section titled “Browser Manager”Provides browser integration for opening URLs and files.
// Open URLs and files in default browsererr := app.Browser.OpenURL("https://wails.io")err := app.Browser.OpenFile("/path/to/document.pdf")Environment Manager
Section titled “Environment Manager”Access to system environment information.
// Get environment infoenv := app.Env.Info()fmt.Printf("OS: %s, Arch: %s\n", env.OS, env.Arch)
// Check system themeif app.Env.IsDarkMode() { // Dark mode is active}
// Open file managererr := app.Env.OpenFileManager("/path/to/folder", false)Dialog Manager
Section titled “Dialog Manager”Organized access to file and message dialogs.
// File dialogsresult, err := app.Dialog.OpenFile(). AddFilter("Text Files", "*.txt"). PromptForSingleSelection()
result, err = app.Dialog.SaveFile(). SetFilename("document.txt"). PromptForSingleSelection()
// Message dialogsapp.Dialog.Info(). SetTitle("Information"). SetMessage("Operation completed successfully"). Show()
app.Dialog.Error(). SetTitle("Error"). SetMessage("An error occurred"). Show()Menu Manager
Section titled “Menu Manager”Application menu creation and management.
// Create and set application menumenu := app.Menu.New()fileMenu := menu.AddSubmenu("File")fileMenu.Add("New").OnClick(func(ctx *Context) { // Handle menu click})
app.Menu.Set(menu)
// Show about dialogapp.Menu.ShowAbout()Key Binding Manager
Section titled “Key Binding Manager”Dynamic management of global key bindings.
// Add key bindingsapp.KeyBinding.Add("ctrl+n", func(window application.Window) { // Handle Ctrl+N})
app.KeyBinding.Add("ctrl+q", func(window application.Window) { app.Quit()})
// Remove key bindingsapp.KeyBinding.Remove("ctrl+n")
// Get all bindingsbindings := app.KeyBinding.GetAll()Context Menu Manager
Section titled “Context Menu Manager”Advanced context menu management (for library authors).
// Create and register context menumenu := app.ContextMenu.New()app.ContextMenu.Add("myMenu", menu)
// Retrieve context menumenu, exists := app.ContextMenu.Get("myMenu")
// Remove context menuapp.ContextMenu.Remove("myMenu")Screen Manager
Section titled “Screen Manager”Screen management and coordinate transformations for multi-monitor setups.
// Get screen informationscreens := app.Screen.GetAll()primary := app.Screen.GetPrimary()
// Coordinate transformationsphysicalPoint := app.Screen.DipToPhysicalPoint(logicalPoint)logicalPoint := app.Screen.PhysicalToDipPoint(physicalPoint)
// Screen detectionscreen := app.Screen.ScreenNearestDipPoint(point)screen = app.Screen.ScreenNearestDipRect(rect)Clipboard Manager
Section titled “Clipboard Manager”Clipboard operations for reading and writing text.
// Set text to clipboardsuccess := app.Clipboard.SetText("Hello World")if !success { // Handle error}
// Get text from clipboardtext, ok := app.Clipboard.Text()if !ok { // Handle error} else { // Use the text}SystemTray Manager
Section titled “SystemTray Manager”System tray icon creation and management.
// Create system traysystray := app.SystemTray.New()systray.SetLabel("My App")systray.SetIcon(iconBytes)
// Add menu to system traymenu := app.Menu.New()menu.Add("Open").OnClick(func(ctx *Context) { // Handle click})systray.SetMenu(menu)
// Destroy system tray when donesystray.Destroy()Autostart Manager
Section titled “Autostart Manager”Registers the application to launch at user login. Picks the appropriate native mechanism per platform: SMAppService or a LaunchAgent plist on macOS, the HKCU\…\Run registry key on Windows, an XDG .desktop entry on Linux.
// Register to launch at loginerr := app.Autostart.Enable()
// With extra launch-time arguments and a custom identifiererr = app.Autostart.EnableWithOptions(application.AutostartOptions{ Identifier: "com.example.myapp", Arguments: []string{"--hidden"},})
// Check / removeenabled, err := app.Autostart.IsEnabled()status, err := app.Autostart.Status() // includes Path + Strategyerr = app.Autostart.Disable()See the Autostart feature page for platform behaviour, identifier rules, and the stale-detection guarantee.