Dioxus Development Kit (SDK)

repository·main·Indexed 43 days ago

https://github.com/dioxuslabs/sdk

A collection of cross-platform crates to extend Dioxus applications with hardware and OS-level capabilities. Includes modules for persistent storage (dioxus-sdk-storage), geolocation (dioxus-sdk-geolocation), system notifications (dioxus-sdk-notification), window management and themes (dioxus-sdk-window), time-based utilities like intervals and debouncing (dioxus-sdk-time), synchronization primitives (dioxus-sdk-sync), and general utility hooks such as use_root_scroll (dioxus-sdk-util).

Tokens
17.7K
Snippets
66
Records
87
Agent score
54%

What's inside Dioxus SDK

  1. Overview of Dioxus Window features

    main

    The dioxus-sdk-window package provides utilities for interacting with window-level properties in Dioxus applications. Currently supported features include:

    • Theme: Utilities for managing or responding to application themes.
    • Window Size: Utilities for monitoring or managing the dimensions of the application window.
  2. Available Dioxus SDK features

    main

    The dioxus-sdk crate provides access to various cross-platform APIs via feature flags. The available modules include:

    • dioxus-sdk-storage: Persistent storage.
    • dioxus-sdk-geolocation: Geolocation services (Web & Windows).
    • dioxus-sdk-notifications: Desktop notifications.
    • dioxus-sdk-window: Window management (includes Theme support for Web, Windows, Mac, and Window Size).
    • dioxus-sdk-time: Time-based utilities (Sleep, Intervals, Debounce, Timeouts).
    • dioxus-sdk-sync: Synchronization primitives (Channels).
    • dioxus-sdk-util: Utility hooks (e.g., use_root_scroll).

    Planned features include Camera, WiFi, and Bluetooth.

  3. Install the Dioxus SDK

    main

    To use the Dioxus SDK in your project, add dioxus-sdk to your Cargo.toml dependencies. The SDK is modular; you must enable specific feature flags to access different sub-crates (e.g., storage, geolocation, notifications, etc.).

    Note: The crates are under active development and may undergo breaking changes.

    [dependencies]
    dioxus-sdk = { version = "0.6", features = [] }
  4. Use timing hooks in dioxus-sdk-time

    main

    The dioxus-sdk-time package provides specialized hooks for managing time-based logic within Dioxus applications. This example demonstrates the usage of two primary hooks:

    1. use_interval: Executes a callback function at a regular, specified interval.
    2. use_debounce: Delays the execution of a callback function until a specified period of inactivity has passed, useful for reducing the frequency of expensive operations like API calls during user input.
    dx serve
  5. Run the use_persistent storage example

    main

    To explore how to create data that persists across sessions using the use_persistent hook, you can run the storage example on different platforms using the Dioxus CLI (dx).

    # For Desktop
    dx serve --platform desktop
    
    # For Web
    dx serve --platform web
    
    # For Fullstack (Web)
    dx serve --platform web --fullstack --features fullstack
    
    # For Fullstack (Desktop)
    dx serve --platform desktop --fullstack --features fullstack