dx-utils
Utility components and functions for Dioxus fullstack apps.
Components
LocalTime
Renders an RFC 3339 datetime string as a <time> element in the browser's
local timezone.
- During SSR: displays UTC (e.g.
2025-06-15 14:30). - On the client (post-hydration):
use_effect+js_sys::Dateconverts to the browser's local timezone. No JavaScript eval or global scripts.
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
datetime |
String |
— | RFC 3339 datetime string (required) |
class |
String |
"" |
Optional CSS class on <time> |
use *;
use LocalTime;
Functions
redirect_external(url: &str)
Redirect to an external URL. Works correctly during both SSR and client-side navigation.
- During SSR: sets HTTP 302 status and a
Locationheader viaFullstackContext, producing a real HTTP redirect before any HTML reaches the browser. - On the client (post-hydration): uses
navigator().replace()withNavigationTarget::Externalfor a client-side navigation.
use *;
use redirect_external;
Usage
Add to your Cargo.toml:
[]
= "0.2"
[]
= ["dx-utils/server"]
Features
| Feature | Description |
|---|---|
server |
Enables SSR redirect via FullstackContext and http crate |
Requirements
- Dioxus 0.7+
- Rust 1.75+
License
MIT