@har-analyzer/components
v0.0.28
Published
Reusable React components for HAR Analyzer
Maintainers
Readme
@har-analyzer/components
Reusable React components and feature modules for HAR Analyzer.
What This Package Includes
- Ready-made dashboard modules for both web apps and browser extensions.
- A configurable HAR entries viewer with compare mode.
- File upload, tabbed HAR entry inspection, and network table components.
- External state helpers for persisting user preferences outside React state.
- HAR utilities and types for parsing/filtering/formatting entry data.
Installation
npm install @har-analyzer/components
# or
yarn add @har-analyzer/components
# or
pnpm add @har-analyzer/componentsPeer Dependencies
Install peer dependencies in your app:
npm install react react-dom \
@cloudscape-design/components \
@cloudscape-design/board-components \
@cloudscape-design/code-view \
@cloudscape-design/collection-hooks \
@cloudscape-design/design-tokens \
@cloudscape-design/global-stylesQuick Start
Most feature modules rely on:
- Cloudscape i18n provider.
- External store provider for persisted preferences.
import { I18nProvider } from '@cloudscape-design/components/i18n';
import enMessages from '@cloudscape-design/components/i18n/messages/all.en';
import type { ExternalStore } from '@har-analyzer/components/external-state';
import { ExternalStoreProvider } from '@har-analyzer/components/external-state';
import HARAnalyzerWebsite from '@har-analyzer/components/har-analyzer-website';
const store: ExternalStore = {
get: async (key) => localStorage.getItem(key) ?? undefined,
set: async (key, value) => localStorage.setItem(key, value),
};
export function App() {
return (
<I18nProvider locale='en' messages={[enMessages]}>
<ExternalStoreProvider store={store}>
<HARAnalyzerWebsite appName='HAR Analyzer' />
</ExternalStoreProvider>
</I18nProvider>
);
}Public API
Root Exports (@har-analyzer/components)
import {
HARAnalyzerWebsite,
HARAnalyzerExtension,
HAREntriesViewer,
HAREntriesFilters,
HAREntriesFiltersProvider,
useFilteredHAREntries,
HARFileUploader,
useFileHAREntries,
ListHAREntries,
ViewHAREntry,
ExternalStoreProvider,
createExternalState,
DEFAULT_HAR_ENTRY_ATTRIBUTES_TO_VALUE_MAP,
getHARContentFromFile,
getHAREntriesFilteredByContentType,
getHAREntriesWithErrorResponse,
getHAREntryAttributesToValuesMap,
getHAREntryHeadersToValuesMap,
getHAREntryId,
getUniqueHeaderNames,
isErrorResponse,
HAR_HEADER_TYPES,
} from '@har-analyzer/components';
import type {
ExternalStore,
HARAnalyzerExtensionProps,
HARAnalyzerWebsiteProps,
HAREntriesViewerProps,
HARFileUploaderProps,
ListHAREntriesProps,
ViewHAREntryProps,
HAREntry,
HARContent,
ContentTypeGroup,
} from '@har-analyzer/components';Feature Module Exports (@har-analyzer/components/<feature>)
external-stateExternalStoreProvidercreateExternalState- type
ExternalStore
har-analyzer-website- default
HARAnalyzerWebsite - type
HARAnalyzerWebsiteProps
- default
har-analyzer-extension- default
HARAnalyzerExtension - type
HARAnalyzerExtensionProps
- default
har-entries-viewer- default
HAREntriesViewer - type
HAREntriesViewerProps
- default
har-entries-filtersHAREntriesFiltersHAREntriesFiltersProvideruseFilteredHAREntries
har-file-uploaderHARFileUploaderuseFileHAREntries- type
HARFileUploaderProps
list-har-entries- default
ListHAREntries - type
ListHAREntriesProps
- default
view-har-entry- default
ViewHAREntry - type
ViewHAREntryProps
- default
Feature Modules
HARAnalyzerWebsite
Drop-in website experience that composes:
- HAR file upload.
- Entries dashboard.
- Theme and content-width preferences via external state.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| logo | ReactNode | No | Header logo element. |
| appName | string | No | Application title. Defaults to HAR Analyzer. |
HARAnalyzerExtension
Extension-oriented viewer with built-in action controls.
Includes:
- Reload action with optional ignore-cache toggle.
- Clear action.
- Upload shortcut button.
- Download current entries as a HAR file.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| pageHAREntries | HAREntry[] | Yes | Entries captured from the active page/session. |
| onClear | () => void | Yes | Called when user clicks clear. |
| onReload | (ignoreCache: boolean) => void | Yes | Called when user clicks reload. |
HAREntriesViewer
Main dashboard module for multi-panel HAR exploration.
Capabilities:
- Responsive board layout.
- Built-in action stripe for compare mode and header selection.
- Inline filtering integration.
- Auto sync between selected rows and detail panels.
- Optional custom actions area via
additionalActions.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| harEntries | HAREntry[] | Yes | Entries displayed in table/detail views. |
| tableTitle | string | No | Header title for the list panel. |
| additionalActions | ReactNode | No | Extra controls rendered on the action stripe. |
HARFileUploader
Uploader for a single .har file.
Validation behavior:
- Requires exactly one file.
- Accepts
.harextension only. - Emits parsed entries and filename on success.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| onUpload | (args: { harEntries: HAREntry[]; harFileName: string }) => void | Yes | Called after parse success. |
| onRemove | () => void | Yes | Called when the uploaded file is removed. |
ListHAREntries
Table view for HAR entries.
Highlights:
- Sortable typed columns (status, time, size, timestamps).
- Dynamic request/response header columns discovered from entries.
- Single- or multi-select mode.
- Persisted table preferences through external state.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| harEntries | HAREntry[] | Yes | Rows to display. |
| selectedHAREntries | HAREntry[] | Yes | Controlled selected rows. |
| onSelectionChange | (selectedHAREntries: HAREntry[]) => void | Yes | Selection callback. |
| enableMultiSelect | boolean | No | Enables multi-selection mode. |
ViewHAREntry
Tabbed detailed inspector for one HAR entry.
Tabs:
- Request headers.
- Request payload.
- Request cookies.
- Response headers.
- Response payload.
- Raw HAR entry JSON.
Props:
| Name | Type | Required | Description |
| --- | --- | --- | --- |
| harEntry | HAREntry | Yes | Entry to inspect. |
| initialSelectedTabId | string | No | Initial active tab id. Defaults to request-headers. |
| onSelectedTabIdChange | (tabId: string) => void | No | Active tab change callback. |
External State Utilities
Use createExternalState to build reusable preference hooks/providers backed by the external store.
import { createExternalState } from '@har-analyzer/components';
export const {
useExternalState: useIsDarkTheme,
Provider: DarkThemeProvider,
} = createExternalState('my-app.theme.dark', false);ExternalStore Interface
interface ExternalStore {
get: (key: string) => Promise<string | undefined>;
set: (key: string, value: string) => Promise<void>;
}HAR Utility Exports
Top-level utility exports include:
getHARContentFromFilegetHAREntriesFilteredByContentTypegetHAREntriesWithErrorResponseisErrorResponsegetUniqueHeaderNamesgetHAREntryHeadersToValuesMapgetHAREntryAttributesToValuesMapgetHAREntryIdHAR_HEADER_TYPESDEFAULT_HAR_ENTRY_ATTRIBUTES_TO_VALUE_MAP- Types:
HARContent,HAREntry,ContentTypeGroup
Development
# from repository root
pnpm install
# develop components package
pnpm --filter @har-analyzer/components dev
# validate components package
pnpm --filter @har-analyzer/components validateUseful scripts in this package:
pnpm --filter @har-analyzer/components lintpnpm --filter @har-analyzer/components check-typespnpm --filter @har-analyzer/components build
Contributing
Contributions are welcome. Please open an issue or pull request:
- https://github.com/theallanjoshua/har-analyzer
