# How Insomnia Handles Configuration Files: Inside the Kong/insomnia Repository

> Discover how Insomnia manages its configuration files within the Kong/insomnia repository. Learn about the central config.json and its role in package.json build scripts.

- Repository: [Kong/insomnia](https://github.com/Kong/insomnia)
- Tags: internals
- Published: 2026-06-27

---

**Insomnia centralizes its runtime metadata in a dedicated JSON file at [`packages/insomnia/config/config.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/config/config.json), which is imported throughout the codebase as a static module and embedded into the application via build scripts defined in [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json).**

The Kong/insomnia repository manages application settings through a **single-source configuration strategy** rather than scattering metadata across multiple files. This approach ensures that the application name, analytics credentials, and bundled plugins remain consistent across both development and packaged builds.

## The Central Configuration File ([`config.json`](https://github.com/Kong/insomnia/blob/main/config.json))

Insomnia stores its core metadata in a static JSON file located at [`packages/insomnia/config/config.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/config/config.json). This file acts as the authoritative source for application identity, user data paths, and third-party service integrations.

### Key Configuration Properties

The file defines several critical categories of settings:

- **Application Identity**: `name`, `appId`, `productName`, and `userDataFolder` determine how the app identifies itself to the operating system and where it stores user collections and environments.
- **Analytics Integration**: `segmentWriteKeys` and `cio` contain credentials for telemetry services.
- **Error Reporting**: `sentryDsn` specifies the endpoint for crash tracking.
- **Plugin Bundling**: `bundlePlugins` lists built-in plugins shipped with the client (e.g., `["@kong/insomnia-plugin-external-vault"]`).

Because this file resides within the source tree, it is automatically bundled with the application during compilation.

## How Insomnia Imports Configuration at Runtime

Throughout the codebase, modules import the configuration directly as a JSON module. This pattern ensures type safety and eliminates the need for runtime file system reads.

### Accessing Configuration in Common Utilities

In [`packages/insomnia/src/common/constants.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/src/common/constants.ts), the configuration is imported to expose helper functions:

```typescript
// src/common/constants.ts
import appConfig from '../../config/config.json';

export const getProductName = () => appConfig.productName;
export const getAppId = () => appConfig.appId;

```

These utilities abstract the raw JSON access, allowing other modules to retrieve values without hardcoding strings or knowing the config file path.

### Using Configuration in the Main Process

The main Electron process accesses the same file for operational logic such as update checks. In [`packages/insomnia/src/main/updates.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/src/main/updates.ts), the `appId` parameter constructs query URLs:

```typescript
// src/main/updates.ts
import appConfig from '../../config/config.json';

fullUrl.searchParams.append('app', appConfig.appId);

```

This ensures the update server receives the correct application identifier regardless of build variants.

## Build-Time Integration with [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json)

While [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json) does not duplicate the configuration values, it references them indirectly through build tooling. The **Electron Builder** configuration consumes [`config.json`](https://github.com/Kong/insomnia/blob/main/config.json) during the packaging phase.

### Electron Builder Configuration

The [`electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/electron-builder.config.js) file reads values from [`config.json`](https://github.com/Kong/insomnia/blob/main/config.json) to set the `productName`, `appId`, and default data directory. This configuration script is invoked by the packaging scripts defined in [`packages/insomnia/package.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/package.json).

### Build Scripts and Packaging

The [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json) defines scripts such as `npm run build` and `npm run package` that trigger the Electron Builder process. During execution, the builder embeds values from [`config.json`](https://github.com/Kong/insomnia/blob/main/config.json) into the final binary metadata. This ensures that runtime behavior—such as where the "Insomnia" folder is created under the user's profile—matches the centralized configuration.

## Practical Examples of Configuration Usage

### Displaying the Product Name in the UI

Components can import the configuration directly to display dynamic branding:

```typescript
import appConfig from '../../config/config.json';

function Header() {
  return <h1>{appConfig.productName}</h1>;
}

```

### Checking for Updates with Config Parameters

The update mechanism uses the configuration to construct request URLs:

```typescript
import appConfig from '../../config/config.json';
import { fetch } from '../../ui/insomnia-fetch';

async function checkForUpdates() {
  const url = new URL('https://updates.insomnia.rest/check');
  url.searchParams.append('app', appConfig.appId);
  const response = await fetch(url.toString());
  // Handle response...
}

```

### Accessing Bundled Plugins

The plugin system retrieves the list of built-in plugins from the same source:

```typescript
import appConfig from '../../config/config.json';

const bundled = appConfig.bundlePlugins; 
// Returns: ["@kong/insomnia-plugin-external-vault"]

```

## Summary

- **Insomnia configuration files** are centralized in [`packages/insomnia/config/config.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/config/config.json) rather than distributed across [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json) or environment variables.
- The configuration is imported as a static JSON module in both the main and renderer processes, making values available at `import` time without file system overhead.
- **Electron Builder** consumes [`config.json`](https://github.com/Kong/insomnia/blob/main/config.json) during the build process defined in [`packages/insomnia/package.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/package.json), embedding metadata into the packaged application.
- Key values include `appId`, `productName`, `userDataFolder`, and `bundlePlugins`, which control application identity, data persistence, and plugin loading.

## Frequently Asked Questions

### Where does Insomnia store its application configuration?

Insomnia stores its runtime metadata in [`packages/insomnia/config/config.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/config/config.json) within the source repository. This file contains the application ID, product name, analytics keys, and bundled plugin list. It does not store user data or collection files here; those are persisted in the folder specified by the `userDataFolder` configuration key.

### Does Insomnia use [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json) for application settings?

No, Insomnia does not store application-specific settings like `appId` or `productName` in [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json). Instead, [`packages/insomnia/package.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/package.json) contains build scripts and dependencies that reference the centralized [`config.json`](https://github.com/Kong/insomnia/blob/main/config.json) file during the packaging process via Electron Builder.

### How does Insomnia access configuration values at runtime?

Modules import the configuration file directly as a JSON module. For example, [`packages/insomnia/src/common/constants.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/src/common/constants.ts) imports [`../../config/config.json`](https://github.com/Kong/insomnia/blob/main/../../config/config.json) and exports helper functions that return specific values like `appConfig.productName`. This pattern ensures configuration values are available synchronously without requiring file system reads.

### Can I modify where Insomnia stores user data?

Yes, the `userDataFolder` key in [`packages/insomnia/config/config.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/config/config.json) defines the default directory name for user data. However, modifying this requires rebuilding the application, as the value is baked into the binary at build time rather than being read from a runtime configuration file.