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

  1. Use the default (relative) path for routing logic within your widget. Use absolute=True only when you need the full URL path including Deephaven’s internal prefix.
  2. Use use_params to extract named route parameters instead of parsing the path string manually.
  3. Use use_navigate to change the current path programmatically, or link with to for 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.

ParametersTypeDefaultDescription
absoluteboolFalseIf True, returns the full absolute path from the URL. If False (default), returns the path relative to the current widget (after /-/).