use_path
use_path is a hook that returns the current URL path relative to the widget’s route space.
Widgets use /-/ to separate Deephaven’s internal router from user-specified widget routing. use_path() returns only the portion after /-/ by default and returns the whole path if the absolute argument is set to True.
Note
Deephaven and all custom components share the path. Avoid using routers, the path, path parameters, and navigation in shared components to prevent conflicts. Do not use the route segment /-/ in your application path as it is reserved for internal use by Deephaven.
Example
Path with Navigation
Use use_path together with use_navigate to build a simple navigation system that updates the path and displays query parameters.
Recommendations
- Use the default (relative) path for routing logic within your widget. Use
absolute=Trueonly when you need the full URL path including Deephaven’s internal prefix. - Use
use_paramsto extract named route parameters instead of parsing the path string manually. - Use
use_navigateto change the current path programmatically, orlinkwithtofor declarative navigation.
API Reference
The /-/ prefix separates platform routing from widget routing. The section after /-/ is the path relative to the current widget. If the widget is not loaded via a route containing /-/, the relative path falls back to /.
Returns: str The current path as a string.
| Parameters | Type | Default | Description |
|---|---|---|---|
| absolute | bool | False | If True, returns the full absolute path from the URL. If False (default), returns the path relative to the current widget (after /-/). |