Skip to content

Example applications ​

Run these applications from a CryKit checkout after completing the prerequisites. Each example demonstrates working application code you can adapt.

Run the demo ​

From the repository root:

sh
shards install
crystal run src/cli.cr -- dev -w -f examples/demo/crykit.yml

dev serves assets from disk and enables asset hotreload for local CSS and tray icons loaded through asset_path. -w also watches Crystal and ECR sources: dev hotpatch updates eligible literal template edits in the running view; dev hotreload rebuilds and restarts after other source edits compile successfully. The demo selects debug logging when CryKit.env.dev?. Running crystal run examples/demo/src/main.cr directly uses production by default.

Shared navigation connects the counter at /, todos at /todos, and file hashes at /files. Try incrementing the counter, adding and filtering todos, or choosing a directory to hash with progress updates and cancellation.

Todos stay in memory while the app runs. Draft input and filters reset when you leave their view. Use Save JSON… to export all todos (including those hidden by a filter), and Open JSON… to import them. Importing asks Overwrite todos? when the current list is nonempty. Cancellation or an invalid file leaves the current list intact; validation and file errors use native error dialogs.

Files contain an array of objects with a nonblank title string and a completed boolean. Internal item IDs are assigned on import:

json
[{ "title": "Try the dialogs demo", "completed": false }]

See Dialogs for file pickers and messages. Native dialogs require macOS 11+.

Notes editor ​

sh
crystal run src/cli.cr -- dev -w -f examples/notes/crykit.yml

The Notes example demonstrates editing, debounced model updates, JSON import/export, and native dialogs. Use it to see how views, models, assets, and background work fit together in a focused application.

Windowless tray application ​

sh
crystal run src/cli.cr -- dev -w -f examples/tray/crykit.yml

The tray example demonstrates a resident macOS application with native menus, custom click actions, live labels, and multiple status items. See System trays for tray lifetime and application configuration.

Explore the application structure ​

The examples follow the structure generated by crykit init, with application code and assets under src/. The demo entry point runs its application, whose startup hooks configure assets, register a handler, and open a window. Handlers, layouts, views, menus, models, services, and assets have their own directories; ECR files live in the layouts' and views' templates/ folders. The todo store belongs to the application; the file-hashing service receives a job and progress callback from its view. Each example includes only the directories it uses: the tray example needs no handlers, layouts, or views.

Continue with Application and Views.

Built with Crystal. Documented with VitePress.