Config files
After following the steps outlined in Getting Started, you'll notice that the OHIF Viewer has data for several studies and their images. You didn't add this data, so where is it coming from?
By default, the viewer is configured to connect to a Amazon S3 bucket that is hosting
a Static WADO server (see Static WADO DICOMWeb).
By default we use default.js for the configuration file. You can change this by setting the APP_CONFIG environment variable
and select other options such as config/local_orthanc.js or config/google.js.
Configuration Files
The configuration for our viewer is in the <root>platform/app/public/config
directory. Our build process knows which configuration file to use based on the
APP_CONFIG environment variable. By default, its value is
config/default.js. The majority of the viewer's features,
and registered extension's features, are configured using this file.
The simplest way is to update the existing default config:
window.config = {
routerBasename: null,
extensions: [],
modes: [],
showStudyList: true,
dataSources: [
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'dicomweb',
configuration: {
friendlyName: 'dcmjs DICOMWeb Server',
name: 'DCM4CHEE',
wadoUriRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado',
qidoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
wadoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
supportsReject: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
enableStudyLazyLoad: true,
supportsFuzzyMatching: true,
supportsWildcard: true,
omitQuotationForMultipartRequest: true,
},
},
],
defaultDataSourceName: 'dicomweb',
};
As you can see a new change in
OHIF-v3is the addition ofdataSources. You can build your own datasource and map it to the internal data structure of OHIF’s > metadata and enjoy using other peoples developed mode on your own data!You can read more about data sources at Data Source section in Modes
The configuration can also be written as a JS Function in case you need to inject dependencies like external services:
window.config = ({ servicesManager } = {}) => {
const { UIDialogService } = servicesManager.services;
return {
cornerstoneExtensionConfig: {
tools: {
ArrowAnnotate: {
configuration: {
getTextCallback: (callback, eventDetails) => UIDialogService.create({...
}
}
},
},
routerBasename: null,
dataSources: [
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'dicomweb',
configuration: {
friendlyName: 'dcmjs DICOMWeb Server',
name: 'DCM4CHEE',
wadoUriRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado',
qidoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
wadoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
supportsReject: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
enableStudyLazyLoad: true,
supportsFuzzyMatching: true,
supportsWildcard: true,
omitQuotationForMultipartRequest: true,
},
},
],
defaultDataSourceName: 'dicomweb',
};
};
Configuration Options
Here are a list of some options available:
-
customizationService: An array of customization module references and inline overrides applied at the global scope. This is how deployers enable optional features like the Appearance & Theming system and configure UI components without modifying core code. See Customization Service for the full syntax reference. -
disableEditing: If true, it disables editing in OHIF, hiding edit buttons in segmentation panel and locking already stored measurements. -
maxNumberOfWebWorkers: The maximum number of web workers to use for decoding. Defaults to minimum ofnavigator.hardwareConcurrencyand what is specified bymaxNumberOfWebWorkers. Some windows machines require smaller values. -
acceptHeader: accept header to request specific dicom transfer syntax ex : [ 'multipart/related; type=image/jls; q=1', 'multipart/related; type=application/octet-stream; q=0.1' ] -
investigationalUseDialog: This should contain an object withoptionvalue, it can be eitheralwayswhich always shows the dialog once per session,neverwhich never shows the dialog, orconfigurewhich shows the dialog once and won't show it again until a set number of days defined by the user, if it's set to configure, you are required to add an additional propertydayswhich is the number of days to wait before showing the dialog again. -
groupEnabledModesFirst: boolean, if set to true, all valid modes for the study get grouped together first, then the rest of the modes. If false, all modes are shown in the order they are defined in the configuration. -
experimentalStudyBrowserSort: boolean, if set to true, you will get the experimental StudyBrowserSort component in the UI, which displays a list of sort functions that the displaySets can be sorted by, the sort reflects in all part of the app including the thumbnail/study panel. These sort functions are defined in the customizationModule and can be expanded by users. -
disableConfirmationPrompts: boolean, if set to true, it skips confirmation prompts for segmentation related prompts. -
showPatientInfo: string, if set to 'visible', the patient info header will be shown and its initial state is expanded. If set to 'visibleCollapsed', the patient info header will be shown but it's initial state is collapsed. If set to 'disabled', the patient info header will never be shown, and if set to 'visibleReadOnly', the patient info header will be shown and always expanded. -
requestTransferSyntaxUID: Request a specific Transfer syntax from dicom web server ex: 1.2.840.10008.1.2.4.80 (applied only if acceptHeader is not set) -
omitQuotationForMultipartRequest: Some servers (e.g., .NET) require themultipart/relatedrequest to be sent without quotation marks. Defaults tofalse. If your server doesn't require this, then setting this flag totruemight improve performance (by removing the need for preflight requests). Also note that if auth headers are used, a preflight request is required. -
maxNumRequests: The maximum number of requests to allow in parallel. It is an object with keys ofinteraction,thumbnail, andprefetch. You can specify a specific number for each type. Forthumbnail, a small pool (around5) is recommended: the study list preview panel fetches a thumbnail per series in parallel, and a larger pool yields little throughput benefit while risking server overload and contention withinteraction/prefetchrequests. -
modesConfiguration: Allows overriding modes configuration.- Example config:
modesConfiguration: {'@ohif/mode-longitudinal': {displayName: 'Custom Name',routeName: 'customRouteName',routes: [{path: 'customPath',layoutTemplate: () => {/** Custom Layout */return {id: ohif.layout,props: {leftPanels: [tracked.thumbnailList],rightPanels: [dicomSeg.panel, tracked.measurements],rightPanelClosed: true,viewports: [{namespace: tracked.viewport,displaySetsToDisplay: [ohif.sopClassHandler],},],},};},},],}},Note: Although the mode configuration is passed to the mode factory function, it is up to the particular mode itself if its going to use it to allow overwriting its original configuration e.g.
function modeFactory({ modeConfiguration }) {return {id,routeName: 'viewer',displayName: 'Basic Viewer',...onModeEnter: ({ servicesManager, extensionManager, commandsManager }) => {...},/*** This mode allows its configuration to be overwritten by* destructuring the modeConfiguration value from the mode fatory function* at the end of the mode configuration definition.*/...modeConfiguration,};} -
showLoadingIndicator: (default to true), if set to false, the loading indicator will not be shown when navigating between studies. -
showStudyList: (default to false), if set to false, the OHIF search (or work list) page will not be shown nor will there be a back button (chevron) in the viewer to navigate to it -
useNorm16Texture: (default to false), if set to true, it will use 16 bit data type for the image data wherever possible which has significant impact on reducing the memory usage. However, the 16Bit textures require EXT_texture_norm16 extension in webGL 2.0 (you can check if you have it here https://webglreport.com/?v=2). In addition to the extension, there are reported problems for Intel Macs that might cause the viewer to crash. In summary, it is great a configuration if you have support for it. -
lossyDownsampling: sets which lossy downsampling Cornerstone3D can use for a volume. The object has three flags:final(defaultfalse): a volume viewport reduces its texture to fit the GPU settings preset. Select the preset with thecornerstone.gpuSettingsPresetcustomization:low-tablet,low,medium,highorhigh-texture-4096. See Select the GPU settings preset.interactive(defaulttrue): a viewport lowers the detail while the user interacts, for example with a larger sample distance during a 3D rotation. The full detail returns when the interaction ends.interleavedLoading(defaulttrue): the loader fills the frames that have not loaded yet with copies of the nearby loaded frames. Each frame becomes exact when its own data loads.
These options are not fully safe on every device. A texture that is too large can lose the WebGL context, and then the user must reload the page.
config/dev.js,config/netlify.js,config/e2e.jsandconfig/customization.jssetlossyDownsampling: { final: true }.config/dev.js,config/netlify.jsandconfig/e2e.jsalso select themediumpreset, and a?customization=gpu/<preset>URL can select a different preset. The other bundled configs keep the defaults.config/default.jsand theconfig/docker-nginx-*.jsrecipes show the setting in a comment. -
useSharedArrayBuffer(default to 'TRUE', options: 'AUTO', 'FALSE', 'TRUE', note that these are strings), for volume loading we use sharedArrayBuffer to be able to load the volume progressively as the data arrives (each webworker has the shared buffer and can write to it). However, there might be certain environments that do not support sharedArrayBuffer. In that case, you can set this flag to false and the viewer will use the regular arrayBuffer which might be slower for large volume loading. -
supportsWildcard: (default to false), if set to true, the datasource will support wildcard matching for patient name and patient id. -
allowMultiSelectExport: (default to false), if set to true, the user will be able to select the datasource to export the report to. -
activateViewportBeforeInteraction: (default to true), if set to false, tools can be used directly without the need to click and activate the viewport. -
autoPlayCine: (default to false), if set to true, data sets with the DICOM frame time tag (i.e. (0018,1063)) will auto play when displayed -
addWindowLevelActionMenu: (default to true), if set to false, the window level action menu item is NOT added to the viewport action corners -
showErrorDetails: determines which runtime environments can display exception and error details caught at theErrorBoundary; acceptable values include:always,dev, andproduction -
runtimePluginOrigins: (default[]) array of origins allowed to serve runtime-loaded extension/mode code referenced by URL inextensions/modes(e.g.['https://cdn.example.com']). Same-origin URLs and relative paths are always allowed. Any other origin is refused unless listed here. -
dangerouslyUseDynamicConfig: Dynamic config allows user to passconfigUrlquery string. This allows to load config without recompiling application. If theconfigUrlquery string is passed, the worklist and modes will load from the referenced json rather than the default .env config. If there is noconfigUrlpath provided, the default behaviour is used and there should not be any deviation from current user experience.
Points to consider while usingdangerouslyUseDynamicConfig:- User have to enable this feature by setting
dangerouslyUseDynamicConfig.enabled:true. By default it isfalse. - At least one gate is required when
enabled: true—origins,regex, or both. If neither is configured, OHIF refuses to load anyconfigUrl, logs a console error, and starts with the built-in configuration. Whichever you set, remember the fetched document controlsdataSources,runtimePluginOrigins, and theextensions/modesdescriptors, so it is as trusted as the viewer's own build. origins(preferred): an array of origins allowed to serve the config document, compared for equality againstnew URL(configUrl).origin. Ports are part of the origin; a full-URL entry allowlists that URL's origin; malformed entries are skipped. There is no pattern subtlety to get wrong.regex: matched against the resolved absolute URL (not the raw query-string value, so a relative or protocol-relativeconfigUrlcannot dodge it). It must be anchored — start the pattern with^— because matching is unanchored: a pattern likeconfig\.example\.comalso acceptshttps://evil.example/?x=config.example.com. An unanchored pattern (including the old/.*/catch-all) is refused with a console error rather than honored. Themflag is rejected for the same reason. To knowingly accept any URL (strongly discouraged), use the anchoredregex: /^/.- Non-
http(s)schemes (e.g.javascript:) are always refused. - When both
originsandregexare set, both must pass. - System administrators can return
cross-origin: same-originwith OHIF files to disallow any loading from other origin. It will block read access to resources loaded from a different origin to avoid potential attack vector. - Example config:
dangerouslyUseDynamicConfig: {enabled: true,// Preferred: exact origin comparison.origins: ['https://config.your-hospital.org'],// Optional extra narrowing, on top of the origin check.regex: /^https:\/\/config\.your-hospital\.org\/viewer\//}
Example 1, one origin, any path under
/configs/:
regex: /^https:\/\/hospital\.com\/configs\//
Example 2, either hospital.com or othersite.com — anchor every alternative:
regex: /^(https:\/\/hospital\.com|https:\/\/othersite\.com)\//
(or simplyorigins: ['https://hospital.com', 'https://othersite.com'])
Example usage:
http://localhost:3000/?configUrl=http://localhost:3000/config/example.json - User have to enable this feature by setting
-
onConfiguration: Currently only available for DicomWebDataSource, this option allows the interception of the data source configuration for dynamic values e.g. values coming from url params or query params. Here is an example of building the dicomweb datasource configuration object with values that are based on the route url params:{namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',sourceName: 'gcpdicomweb',configuration: {friendlyName: 'GCP DICOMWeb Server',name: 'gcpdicomweb',imageRendering: 'wadors',thumbnailRendering: 'wadors',enableStudyLazyLoad: true,supportsFuzzyMatching: false,supportsWildcard: false,singlepart: 'bulkdata,video,pdf',onConfiguration: (dicomWebConfig, options) => {const { params } = options;const { project, location, dataset, dicomStore } = params;const pathUrl = `https://healthcare.googleapis.com/v1/projects/${project}/locations/${location}/datasets/${dataset}/dicomStores/${dicomStore}/dicomWeb`;return {...dicomWebConfig,wadoRoot: pathUrl,qidoRoot: pathUrl,wadoUri: pathUrl,wadoUriRoot: pathUrl,};},},},
This configuration would allow the user to build a dicomweb configuration from a GCP healthcare api path e.g. http://localhost:3000/projects/your-gcp-project/locations/us-central1/datasets/your-dataset/dicomStores/your-dicom-store/study/1.3.6.1.4.1.1234.5.2.1.1234.1234.123123123123123123123123123123
You can stack multiple panel components on top of each other by providing an array of panel components in the rightPanels or leftPanels properties.
For instance we can use
rightPanels: [[dicomSeg.panel, tracked.measurements], [dicomSeg.panel, tracked.measurements]]
This will result in two panels, one with dicomSeg.panel and tracked.measurements and the other with dicomSeg.panel and tracked.measurements stacked on top of each other.
Study Prefetcher
You can enable the study prefetcher so that OHIF loads the next/previous series/display sets based on the proximity to the current series/display set. This can be useful to improve the user experience
studyPrefetcher: {
/* Enable/disable study prefetching service (default: false) */
enabled: true,
/* Number of displaysets to be prefetched (default: 2)*/
displaySetsCount: 2,
/**
* Max number of concurrent prefetch requests (default: 10)
* High numbers may impact on the time to load a new dropped series because
* the browser will be busy with all prefetching requests. As soon as the
* prefetch requests get fulfilled the new ones from the new dropped series
* are sent to the server.
*
* TODO: abort all prefetch requests when a new series is loaded on a viewport.
* (need to add support for `AbortController` on Cornerstone)
* */
maxNumPrefetchRequests: 10,
/* Display sets loading order (closest (deafult), downward or upward) */
order: 'closest',
},
More on Accept Header Configuration
In the previous section we showed that you can modify the acceptHeader
configuration to request specific dicom transfer syntax. By default
we use acceptHeader: ['multipart/related; type=application/octet-stream; transfer-syntax=*'] for the following
reasons:
-
Ensures Optimal Transfer Syntax: By allowing the server to select the transfer syntax, the client is more likely to receive the image in a syntax that's well-suited for fast transmission and rendering. This might be the original syntax the image was stored in or another syntax that the server deems efficient.
-
Avoids Transcoding: Transcoding (converting from one transfer syntax to another) can be a resource-intensive process. Since the OHIF Viewer supports all transfer syntaxes, it is fine to accept any transfer syntax (transfer-syntax=*). This allows the server to send the images in their stored syntax, avoiding the need for costly on-the-fly conversions. This approach not only saves server resources but also reduces response times by leveraging the viewer's capability to handle various syntaxes directly.
-
Faster Data Transfer: Compressed transfer syntaxes generally result in smaller file sizes compared to uncompressed ones. Smaller files transmit faster over the network, leading to quicker load times for the end-user. By accepting any syntax, the client can take advantage of compression when available.
However, if you would like to get compressed data in a specific transfer syntax, you can modify the acceptHeader configuration or
requestTransferSyntaxUID configuration.
Data Source: stackRetrieveOptions
At the data source configuration level, you can set stackRetrieveOptions to customize Cornerstone stack image retrieval. Merged with defaults; only specify overrides. For example, set streaming: false when the data source returns uncompressed DICOM (e.g. application/octet-stream only) to avoid black image on load:
configuration: {
acceptHeader: ['application/octet-stream'],
stackRetrieveOptions: {
retrieveOptions: { single: { streaming: false } },
},
}
Data Source: volumeRetrieveOptions
At the data source configuration level, you can set volumeRetrieveOptions to select the retrieve stages of a volume. The value is the name of a Cornerstone3D ProgressiveRetrieveImages stage set, or a { stages } object. The default is 'coarseInterleavedRetrieveStages'. A hanging protocol with an imageLoadStrategy does not use these stages.
The 3.13 default was 'interleavedRetrieveStages'. That stage set has a lossy first pass, which is fast on an HTJ2K server. To use it again:
configuration: {
volumeRetrieveOptions: 'interleavedRetrieveStages',
}
Runtime Extensions and Modes
This section is the reference for writing a runtime extension descriptor and
the runtimePluginOrigins allowlist. Other pages (the Runtime Extensions page,
deployment docs, plugin author guides) link here; if their wording differs,
this section wins. What the viewer does with a descriptor is specified in the
runtime plugins specification;
if this section and the specification differ, the specification wins.
Besides bundled (build-time) plugins declared in pluginConfig.json, the
viewer can load prebuilt extension and mode bundles at runtime — no viewer
rebuild. Entries in window.config.extensions and window.config.modes may
be descriptor objects instead of plain strings:
window.config = {
// ...
runtimePluginOrigins: ['https://plugins.example.com'],
extensions: [
// Same-origin UMD bundle (UMD builds MUST set globalName):
{
packageName: '@acme/ohif-extension-ai',
importPath: '/plugins/acme-ai/1.2.0/index.umd.js',
globalName: '@acme/ohif-extension-ai',
coreVersionRange: '>=3.14.0-beta.0 <4',
styles: ['/plugins/acme-ai/1.2.0/index.css'],
},
// Cross-origin ESM bundle (globalName omitted; integrity REQUIRED):
{
packageName: '@acme/ohif-extension-cloud',
importPath: 'https://plugins.example.com/cloud/index.mjs',
integrity: 'sha384-...',
},
],
};
A bundled mode may list a runtime-loaded extension's packageName in its
extensionDependencies; the dependency is resolved through the runtime
loader's cache.
Descriptor fields
| Field | Required | Description |
|---|---|---|
packageName | yes | MUST equal the extension/mode id exported by the package. The loader refuses modules whose id differs. |
importPath | yes | Where to fetch the bundle: an absolute http(s) URL, a /rooted path, or a path relative to PUBLIC_URL. |
globalName | UMD bundles only | Strict format discriminator — see below. UMD builds MUST set it (normally equal to packageName, matching the bundle's output.library name); ESM builds MUST omit it. |
coreVersionRange | no | semver range checked against the host version (the build's version.txt value, exposed as VERSION_NUMBER), prereleases included. Fail-closed: if the host version does not satisfy the range, the load is refused with status version-mismatch BEFORE any network import. Note version.txt can lag package.json; target the value shown as hostVersion in the audit records. |
integrity | cross-origin loads | sha256-, sha384-, or sha512- prefix plus the base64 digest of the bundle. REQUIRED when importPath resolves to a different origin; same-origin loads skip integrity verification. See Computing the integrity value. |
styles | no | Stylesheet URLs appended to the document head as link rel="stylesheet" tags. Resolved and origin-checked with the same rules as importPath. |
globalName is a strict format discriminator
The presence or absence of globalName tells the loader how the bundle was
built. There is no fallback chain and the loader never defaults
globalName to packageName:
globalNamepresent = UMD: after the script evaluates, the loader returnswindow[globalName]— nothing else. If that global is undefined, the load fails withimport-error. If it holds a whole module whosedefaulthas anid(whatpnpm create ohifbuilds), the loader takes thatdefault.globalNameabsent = ESM: the loader dynamically imports the module and returns the namespace'sdefaultexport — never a window global. A missing default export fails withimport-error.
The audit record's format field ('umd' or 'esm') derives from this
discriminator.
Origin allowlist: runtimePluginOrigins
Runtime plugin code (and stylesheets) may only be served from allowlisted origins. The allowlist is deny-by-default:
- The viewer's own origin is always implicitly allowed.
- Every other origin must be listed in
window.config.runtimePluginOrigins(an array of origin strings, e.g.['https://plugins.example.com']). Ports are part of the origin. Full-URL entries allowlist that URL's origin; malformed entries are skipped, never fatal. - Non-allowlisted origins are refused with status
refused-originbefore any code is fetched.
Function-style app configs are supported: at init the viewer stashes
appConfig.runtimePluginOrigins onto
window.__ohif.runtimePluginOrigins, which takes precedence over
window.config.runtimePluginOrigins when both exist.
Where integrity is enforced
integrity is enforced on the descriptor path only. Three paths can load
plugin code, and they sit at deliberately different trust levels:
| Path | Origin allowlist | integrity |
|---|---|---|
Build-time importPath in pluginConfig.json (public entries) | not applied | not applied |
URL fallthrough / appConfig.peerImport (a URL or bare specifier passed to loadModule that no descriptor and no build-time entry declares) | enforced | not applied |
Runtime descriptor in extensions / modes (this section) | enforced | required cross-origin |
The rationale:
- A build-time
importPathis compiled into the bundle by whoever built the viewer. Changing it requires editingpluginConfig.jsonand rebuilding — the same trust level as editing the app's own source — so it is trusted outright and imported directly, even when the URL is absolute and cross-origin. - On the fallthrough path the allowlist is the trust decision: an
allowlisted origin is trusted to serve code. There is no descriptor to carry a
digest, and callers pass library specifiers rather than pinned bundles, so no
integrity,
coreVersionRange, oridcheck applies. - A descriptor has somewhere to put a digest and the result is registered as an extension/mode, so it gets the strictest treatment.
Deployment consequence: adding an origin to runtimePluginOrigins grants
it unverified script execution through the fallthrough path, even though a
descriptor pointing at that same origin would be refused without an integrity
value. Allowlist only origins you control or otherwise trust to serve code, and
keep the list as small as the deployment needs.
Computing the integrity value
The value is one <algorithm>-<base64 digest> string, for example
sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC. The
loader hashes the exact bytes importPath serves and compares the result.
What to hash. Hash the bundle you built and checked — normally
dist/index.umd.js, the file you publish — not a copy downloaded afterwards.
Then download the served copy (from the CDN, say) and hash it too, to confirm it
matches. A value computed from the served file only proves that the file is
what it is.
Commands. Each prints the complete value, ready to paste:
# bash / zsh / Git Bash
echo "sha384-$(openssl dgst -sha384 -binary dist/index.umd.js | openssl base64 -A)"
# PowerShell (5.1 and 7)
$bytes = [IO.File]::ReadAllBytes((Resolve-Path dist/index.umd.js))
'sha384-' + [Convert]::ToBase64String([Security.Cryptography.SHA384]::Create().ComputeHash($bytes))
# Node, from any shell
node -e "const c=require('crypto'),f=require('fs');console.log('sha384-'+c.createHash('sha384').update(f.readFileSync(process.argv[1])).digest('base64'))" dist/index.umd.js
In PowerShell, keep the Resolve-Path: [IO.File] resolves a relative path
against the process's folder, not PowerShell's current location.
Common mistakes. Each of these ends in status integrity-failed:
- Hex instead of base64.
sha384sum,shasumandGet-FileHashprint hex; the value needs the base64 form. - A prefix that doesn't match the digest, such as
sha256-in front of a SHA-384 digest. - Several values separated by spaces. HTML's
integrityattribute allows that; this loader takes exactly one. - A different copy of the file: a bundle rebuilt after you hashed it, a
.min.jsvariant generated by the CDN, or line endings changed by git on Windows. - A CDN URL without an exact version, such as
.../npm/@acme/extension-foo/dist/index.umd.jsor...@latest/.... It works until the next publish, when the URL starts serving the new file and the hash no longer matches. Pin the version inimportPath(@1.2.3) and update the URL and the hash together.
Audit surface: window.__ohif.runtimePlugins
Every runtime load attempt — success AND failure — appends a record to
window.__ohif.runtimePlugins:
{
packageName: '@acme/ohif-extension-ai',
kind: 'extension', // or 'mode': which list the descriptor came from
importPath: '/plugins/acme-ai/index.umd.js',
resolvedUrl: 'https://viewer.example.com/plugins/acme-ai/index.umd.js',
status: 'loaded', // see the status enum below
hostVersion: '3.14.0-beta.49', // the host build's version.txt value
requiredRange: '>=3.14.0-beta.0 <4', // the descriptor's coreVersionRange
format: 'umd', // derived from the globalName discriminator
error: undefined, // failure message when status is not 'loaded'
durationMs: 142,
timestamp: '2026-07-11T00:00:00.000Z',
}
status is one of 'loaded', 'refused-origin', 'integrity-failed',
'version-mismatch', 'import-error', 'registration-error',
'duplicate-of-built-in'. Records carry
both the host version and the descriptor's required range so version skew is
diagnosable from the console. kind is 'extension' or 'mode' for a
descriptor, and absent on records from the URL fallthrough path, which loads
libraries rather than plugins. Failures additionally surface one error toast
each once the UI mounts (toasts are suppressed in test environments — assert
on the audit array instead).
A built-in extension (from pluginConfig.json) that fails to register when its
mode opens also appends a record, with importPath: '(built-in)' and status
'registration-error', so its failure is surfaced the same way.
A descriptor whose packageName is also declared in pluginConfig.json is
refused before anything is fetched: the built-in copy is always the one used.
Its record has status 'duplicate-of-built-in' and says how to resolve the
conflict, and it is surfaced as a warning rather than an error, since the viewer
still works. To use the runtime bundle instead, remove the pluginConfig.json
entry and rebuild.
CSP and CORS requirements
The deployment docs describe an optional CSP_HEADER for the official
Docker/nginx image. Its baseline is OHIF's own reference minimum, not a
standard, and no deployment runs it unchanged; the
deployment guide gives the
working form. The minimum is:
default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; worker-src 'self' blob:; object-src 'none'; base-uri 'self'
Two caveats for runtime plugins:
- Cross-origin plugins need more. A plugin loaded from another origin needs extra CSP directives, and that origin must send CORS headers; the deployment guide's Extending the baseline says which. Same-origin plugins need neither.
- Interim
'unsafe-inline'note. As written, the baseline'sscript-src 'self' 'wasm-unsafe-eval'also blocks the viewer's own two inline bootstrap scripts inindex.html(thewindow.PUBLIC_URLbootstrap andbrowserImportFunction), so the app itself cannot boot under it. Until the automated inline-script-hash handshake ships, deployments enablingCSP_HEADERmust interim-add'unsafe-inline'toscript-src(or add the per-deploymentsha256-...hashes of those two inline scripts — the hashes vary withPUBLIC_URL).
Shared host packages
The host assigns its singleton copies of 16 packages to window, keyed by
full package name, just before it loads the first runtime plugin; runtime
plugin builds externalize them instead of bundling their own copies: react,
react-dom, react/jsx-runtime, @ohif/core, @ohif/ui-next, @ohif/i18n,
@ohif/extension-default, @ohif/extension-cornerstone, @cornerstonejs/core,
@cornerstonejs/tools, dcmjs, gl-matrix, react-router, react-router-dom,
i18next, react-i18next. @ohif/ui is NOT shared: it is legacy and a
forbidden import for runtime plugins (use @ohif/ui-next).
React Router and i18next are shared so a plugin uses the viewer's Router and
its one i18next instance, with OHIF's translations and language switching. A
plugin's own copy of either sees neither: useLocation and Link throw
outside the viewer's Router, and translations show their raw keys.
Runtime plugins are built against the host's versions of the third-party packages, and get the host's copies when they load:
| Package | Version |
|---|---|
react, react-dom | 19 |
react-router, react-router-dom | 6 |
i18next | 19 |
react-i18next | 12 |
@cornerstonejs/core, @cornerstonejs/tools | 5 |
dcmjs | 0.52 |
gl-matrix | 3 |
Set your plugin's peer ranges to match. A new major version of any of these
(for dcmjs, a new 0.x minor) is a breaking change for runtime plugins and is
listed in the migration guide.
Every extension and mode built into the viewer is also shared on window
under its package name once it has loaded (the whole module, named exports
included). These globals carry no compatibility promise. Extensions marked
"default": false in pluginConfig.json load only when a mode needs them; to
import one from a runtime plugin, also list it by name in extensions. See
Runtime plugins.
Any other package that a plugin build leaves out has no global, and is
undefined in a runtime plugin: vtk.js, the @cornerstonejs/* packages other
than core and tools, and an @ohif/* package that is not compiled into the
viewer. A fork that builds its own viewer can share more of them. See
Sharing more libraries from a fork.
Environment Variables
We use environment variables at build and dev time to change the Viewer's
behavior. We can update the HTML_TEMPLATE to easily change which extensions
are registered, and specify a different APP_CONFIG to connect to an
alternative data source (or even specify different default hotkeys).
| Environment Variable | Description | Default |
|---|---|---|
HTML_TEMPLATE | Which HTML template to use as our web app's entry point. Specific to PWA builds. | index.html |
PUBLIC_URL | The route relative to the host that the app will be served from. Specific to PWA builds. | / |
APP_CONFIG | Which [configuration file][config-file] to copy to output as app-config.js | config/default.js |
PROXY_TARGET | When developing, proxy requests that match this pattern to PROXY_DOMAIN | undefined |
PROXY_DOMAIN | When developing, proxy requests from PROXY_TARGET to PROXY_DOMAIN | undefined |
OHIF_PORT | The port the development server listens on. | 3000 |
You can also create a new config file and specify its path relative to the build
output's root by setting the APP_CONFIG environment variable. You can set the
value of this environment variable a few different ways:
Add a temporary environment variable in your shell- Previous
react-scriptsfunctionality that we need to duplicate withdotenv-webpack
- Previous
Add environment specific variables in.envfile(s)- Previous
react-scriptsfunctionality that we need to duplicate withdotenv-webpack
- Previous
- Using the
cross-envpackage in a npm script:"build": "cross-env APP_CONFIG=config/my-config.js react-scripts build"
After updating the configuration, yarn run build to generate updated build
output.