Introducing a new way to review your PRs.

Read the announcement

getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

View on GitHub

20 documents · Updated Nov 11, 2026

docs / frontend-services-and-extensions

Frontend services and extensions

The frontend services form the browser-side boundary between feature pages and the backend API. They also hold shared session state, shape data for page use, manage browser behavior, and provide extension points for routes, components, settings, and access rules. See the parent Web client application page for the wider application flow.

Service boundary

Client services give feature pages one common way to request data and save changes. The shared Axios service returns response data in a consistent form, adds API-key access when needed, refreshes CSRF state, and asks the user to restore an expired session. This keeps transport and session behavior outside page components.

The main services map product areas to backend resources:

Service areaProduct role
Queries and query resultsBuild parameter values, start query work, track job state, and expose rows and columns to visualizations.
Dashboards, widgets, and visualizationsLoad and save dashboard presentation, widget layout, visualization links, public access, favorites, and forks.
Data sourcesManage connections and turn schema jobs into table and column data for query pages.
Alerts and subscriptionsManage alert rules, evaluation, mute state, and alert watchers.
Users, groups, and destinationsSupport administration pages for accounts, access groups, and delivery targets.
Organization settings and statusRead organization options and shared object counts for the signed-in application.

This diagram shows how a feature page uses a service boundary and how long-running query work returns to the page.

flowchart LR
    Page[Feature page or component] --> Service[Client service]
    Service --> Transport[Shared API transport]
    Transport --> API[Backend API]
    API -->|data or job| Service
    Service --> Page
    Service --> Result[Query result state]
    Result -->|poll job and load result| API

References: client/…/axios.js• L8-53 client/…/query.js• L377-397 client/…/query-result.js• L456-503 client/…/data-source.js• L13-39 client/…/dashboard.js• L160-180 client/…/alert.js• L30-40

Session and configuration state

The authentication service is the shared source for the current user, client configuration, and server messages. A client configuration is the server-provided set of browser options. The service loads it from the configuration API and merges it into shared state so pages and policy rules can use the same values.

Signed-in pages require a session before they render. During that gate, the application refreshes organization status and the active policy. Public or API-key pages load configuration with the supplied key and stop when public URLs are disabled. Organization settings use a separate service to save server-backed settings and report the result through the shared notification service.

Shared state or serviceRole in the client
currentUserAnswers common permission and ownership questions for pages and policies.
clientConfigCarries server options such as public URL access and refresh choices.
organizationStatusSupplies current counts used by the signed-in application.
organizationSettingsReads and saves organization-level settings.

References: client/…/auth.js• L7-57 client/…/auth.js• L59-125 client/…/routeWithUserSession.tsx• L28-76 client/…/routeWithApiKeySession.jsx• L13-62 client/…/organizationStatus.js• L3-13 client/…/organizationSettings.js• L4-15

Query and parameter state

The query service turns a saved query into a browser model that can read parameters from the URL and prepare values for execution. A parameter is a named input with a type, display value, execution value, and URL form. The parameter family supports text, number, pattern-checked text, enum, query-backed dropdown, date, and date-range inputs. Query parameters can remain local to a widget or map to a dashboard-level value, which lets several visualizations respond to one dashboard control.

Dashboard models collect those mappings into shared controls. They merge saved dashboard values with URL values and keep the configured dashboard order, so one input can drive several widgets while links can still select a value.

Query results present one state model to the pages. The model covers waiting, processing, loading, completion, and failure. It can use a cached result, start a new job, poll job status, load the finished data, and expose rows, columns, filters, logs, and download links. Missing parameter values become a failed result before the client sends a query.

References: client/…/query.js• L47-145 client/…/query.js• L210-335 client/…/query-result.js• L52-114 client/…/query-result.js• L120-215 client/…/query-result.js• L404-503 client/…/Parameter.js• L3-16 client/…/Parameter.js• L67-120 client/…/DateParameter.js• L42-89 client/…/DateRangeParameter.js• L132-224 client/…/EnumParameter.js• L4-72 client/…/QueryBasedDropdownParameter.js• L5-76 client/…/TextParameter.js• L4-17 client/…/TextPatternParameter.js• L4-26 client/…/dashboard.js• L189-232

Browser utility services

Small shared services keep browser concerns consistent across pages. The location service owns path, search, and hash state and notifies the router when navigation changes. URL helpers resolve and normalize links, while absoluteUrl keeps generated links on the current host and protocol.

Keyboard shortcuts provide a shared browser-wide action boundary. A page can bind or unbind one handler to one or more key combinations, while the service presents platform-specific modifier names such as Ctrl or Cmd. It also prevents equivalent names for the same key event from running one handler twice while still allowing separate handlers to share a key.

Other utilities cover user feedback, browser conditions, and safe content display. The notification wrapper gives pages one message interface with common defaults. Markdown conversion renders supported markup while treating source HTML as text, and sanitization removes unsafe output before it reaches the page. A debounced search hook avoids work for each keystroke and ignores results from an older search. Pagination exposes a shared page-navigation helper.

References: client/…/location.js• L7-105 client/…/url.js• L8-25 client/…/utils.js• L1-6 client/…/KeyboardShortcuts.js• L5-72 client/…/KeyboardShortcuts.test.js• L10-39 client/…/notification.js• L1-20 client/…/sanitize.js• L1-25 client/…/markdown.js• L1-16 client/…/useSearchResults.js• L4-32 client/…/index.js• L1 client/…/offline-listener.js• L3-20 client/…/notifications.js• L19-46 client/…/recordEvent.js• L4-25 client/…/resizeObserver.js• L1-32

Extension points

Extensions are optional browser modules loaded during client setup. The setup loads built-in pages and visualizations first, then loads JavaScript modules from client/app/extensions; a module can expose an init function to add or replace client behavior. This order allows an extension to override a route that the base application already registered.

The client exposes four useful extension boundaries:

Extension pointPurpose
Route registryAdd or replace a page route with a path, title, and render function. Route matching favors specific paths before parameterized paths.
Dynamic component registryReplace a named component at runtime. A fallback remains available when no replacement is registered.
Settings menu registryAdd settings tabs with order, active-path rules, and permission-based visibility.
Policy objectReplace product access and feature-choice rules without changing page code.

Routes are registered before extensions run. The route registry sorts static and specific paths before parameterized paths, so a route such as /queries/new is not treated as a query ID. A registered component can update active consumers, and a policy replacement becomes the shared policy used by page gates and model methods. These boundaries let an extension change a page surface without changing the core feature service contracts.

References: client/…/index.js• L7-12 client/…/index.js• L39-53 client/…/routes.ts• L6-70 client/…/routes.test.js• L4-64 client/…/DynamicComponent.jsx• L5-50 client/…/settingsMenu.js• L5-51 client/…/SettingsWrapper.jsx• L8-35 client/…/index.js• L1-8 client/…/DefaultPolicy.js• L4-66

Extension lifecycle

The browser starts by loading configuration modules and registering the core page and visualization surfaces. It then registers extension modules before mounting the application. The router consumes the final route list, while dynamic components and settings menus use their registries when their owning pages render.

The lifecycle is:

  1. Load shared configuration and built-in assets.
  2. Register built-in visualizations and routes.
  3. Run extension initializers.
  4. Mount the application and let the router resolve the current path.
  5. Let authenticated route wrappers load the session, organization status, and policy before showing protected pages.

References: client/…/index.js• L1-13 client/…/index.js• L33-53 client/…/index.js• L1-11 client/…/index.jsx• L7-44 client/…/Router.jsx• L37-121 client/…/routeWithUserSession.tsx• L28-76

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to response or error handling in client/…/axios.js can affect every feature service and both signed-in and API-key pages.
  • Changes to clientConfig names or loading must be checked against policy rules and settings pages that read the same values.
  • Changes to query parameter normalization, URL forms, or execution values must remain compatible with dashboard-level mappings, saved links, and backend query values.
  • Changes to dashboard value merging or widget layout must preserve both URL-driven controls and valid placement for new widgets.
  • Changes to query result status or polling behavior must preserve the states consumed by query pages and visualizations.
  • Changes to keyboard shortcut names or binding rules must preserve platform modifier labels and the one-handler-per-key-event contract.
  • Changes to Markdown conversion or sanitization must preserve the boundary between formatted text and executable HTML.
  • Changes to route registration order or route paths must preserve extension overrides and the router’s path-specific matching.
  • Changes to a dynamic component name must update both the registry call and every consuming DynamicComponent.
  • Changes to an extension initializer must preserve the startup order that makes core routes available before overrides run.

Important failure modes

TriggerConsequenceGuard
A request returns an expired session response.Protected pages can keep an invalid session and fail later API calls.The shared transport starts one session-restore flow and excludes the session request itself.
A query job fails or never reaches a result state.Query pages and widgets show no usable data.QueryResult exposes processing and failed states and reports server or connection errors.
A required query parameter is absent.The client must not run the query with incomplete input.Query returns a failed result with the missing parameter names.
Dashboard values and URL values use conflicting sources.Dashboard controls can show a value different from the link or saved dashboard state.Dashboard parameter models merge the values before URL-specific parsing.
Markdown output is inserted without the sanitization step.User-provided or remote content can add unsafe links or HTML to the page.Markdown treats source HTML as text and sanitize removes unsafe output before display.
A search response arrives after a newer search or after unmount.Old data can replace the current search result or update a removed component.useSearchResults accepts only the current search term while the component is active.
Public URL access is disabled for an API-key route.The public page stays empty instead of exposing the route.The API-key session wrapper checks the loaded client configuration before rendering.
A handler is bound through equivalent shortcut names for one key event.The same action can run more than once.KeyboardShortcuts tracks handlers per event and runs each handler once.
An extension registers a route or component with an invalid shape.The route or replacement is ignored, so the base page or fallback remains active.Registries accept only valid route objects or named component functions.

Key files

FileWhy to read it
client/…/axios.jsDefines the shared API boundary and session recovery behavior.
client/…/auth.jsDefines shared user, configuration, and session state.
client/…/query.jsShows how query models, parameters, and API actions meet.
client/…/query-result.jsShows the client view of cached results and asynchronous jobs.
client/…/Parameter.jsDefines the shared parameter contract for input, URL, and execution values.
client/…/DateRangeParameter.jsShows date-range presets and their URL and query forms.
client/…/dashboard.jsShows how dashboard data becomes page-ready models, shared controls, and widgets.
client/…/data-source.jsShows how data source schema work reaches query features.
client/…/KeyboardShortcuts.jsDefines the shared shortcut binding and platform modifier behavior.
client/…/KeyboardShortcuts.test.jsShows the one-handler-per-event and shared-key contracts.
client/…/markdown.jsDefines the shared Markdown-to-HTML behavior.
client/…/sanitize.jsDefines the safety boundary for generated HTML.
client/…/useSearchResults.jsShows the shared debounced search behavior.
client/…/index.jsDefines startup registration and extension loading order.
client/…/routes.tsDefines the route extension boundary.
client/…/routes.test.jsShows the required precedence between static and parameterized routes.
client/…/DynamicComponent.jsxDefines named component replacement and fallback behavior.
client/…/index.jsDefines the swappable access-rule boundary.
client/…/settingsMenu.jsDefines settings tab registration and visibility.
client/…/routeWithUserSession.tsxShows the protected-page gate around shared services and policy.