)`.
## Package Name `packageName`
The `packageName` field is mainly used by the Node.js ecosystem. When defining this value, follow the standard naming conventions used in `package.json`.
## Version `version`
The `version` field represents the current version of your application. It should follow **semantic versioning** with `major.minor.patch` format. Examples include `1.0.0`, `1.0.1`, or `12.9.8`.
## Domain `domain`
The `domain` field specifies the starting URL of the application. When the app runs, this URL will be opened automatically. It can be either an `http` or `https` URL.
## Icons `icons`
The `icon` field sets the application icon paths. You must provide separate icons for **Windows**, **Linux**, and **macOS**.
Each icon path should be defined as an array of folder names ending with the icon file name.
Paths should be relative to the configuration file directory.
```json theme={null}
icons: {
mac: ['folder', 'mac', 'icon.icns'], // Path: folder/mac/icon.icns
windows: ['folder', 'windows', 'icon.ico'], // Path: folder/windows/icon.ico
linux: ['folder', 'linux', 'icon.png'] // Path: Folder/linux/icon.png
}
```
## Window Startup `windowStartup`
The `windowStartup` field defines how the application launches
### ` shouldShowBeforeLoadingComplete`
If this is`true`, the application will not display until the page finishes loading. If `false`, the application loads immediately, which may show a blank screen briefly.
It is recommended to set this to `true`.
### `shouldEnableSplashScreen`
If this is `true`, a splash screen will be displayed while the page loads. You can provide a custom HTML splash screen; otherwise, the default splash screen is used. The splash screen only appears if the page loading takes noticeable time; in most cases, the page loads immediately.
## Window Size `windowSize`
The `windowSize` field defines the default dimensions of the main application window:
### `height`
The default height of the application window defines its initial vertical size when the app launches. The value must be greater than `0`.
### `width`
The default width of the application window sets its initial horizontal size. Like height, it must also be greater than `0`.
### `minHeight`
The minimum height specifies the smallest vertical size the window can be resized to. It must be greater than `0` and less than the default height. Users will not be able to resize the window below this value.
### `minWidth`
The minimum width defines the smallest horizontal size the window can be resized to. It must be greater than `0` and less than the default width. Users cannot reduce the window width below this limit.
## Window Layout `windowLayout`
The `windowLayout` field contains nested properties to control the main window’s appearance and behavior:
### `shouldHideTitleBar`
The `shouldHideTitleBar` property, when set to `true`, hides the default OS-specific title bar from the window. This is useful when creating a custom title bar or a frameless window design.
### `shouldEnableFrame`
The `shouldEnableFrame` property controls the visibility of the application frame. If set to `false`, the standard window frame is removed, allowing for a fully customized window appearance.
### `shouldDisableAutoHideCursor`
The `shouldDisableAutoHideCursor` property determines cursor behavior while typing. When set to `true`, the cursor will remain visible instead of automatically hiding, which can improve usability in certain input-heavy applications.
### `shouldHaveRoundCorners`
The `shouldHaveRoundCorners` property enables OS-specific rounded corners on the window when set to `true`. This provides a more modern and native look, particularly on macOS and Windows.
### `shouldEnableShadows`
The `shouldEnableShadows` property adds default OS-specific shadows to the window when set to `true`. This enhances visual depth and distinguishes the application window from the background, improving overall aesthetics and user experience.
## Window Options `windowOptions`
### `shouldMovable`
The `shouldMovable` property determines whether the application window can be moved by the user. When set to `true`, users can drag the window around the screen; setting it to `false` locks the window in place.
### `shouldMinimizable`
The `shouldMinimizable` property controls whether the window can be minimized. If `true`, the minimize button is enabled, allowing users to send the window to the taskbar or dock.
### `shouldMaximizable`
The `shouldMaximizable` property defines whether the window can be maximized to fill the screen. When set to `true`, the maximize button is active; if `false`, users cannot expand the window.
### `shouldClosable`
The `shouldClosable` property determines if the window can be closed by the user. If `true`, the close button is enabled; setting it to `false` prevents accidental or manual closure of the application.
### `shouldFocusable`
The `shouldFocusable` property controls whether the window can receive focus. If `true`, the window can be selected and interacted with; if `false`, it remains unfocused and ignores user input.
### `shouldFullscreenable`
The `shouldFullscreenable` property specifies whether the window can enter fullscreen mode. When set to `true`, users can toggle fullscreen, providing a distraction-free experience.
### `shouldRestoreState`
The `shouldRestoreState` property determines whether the window should remember its last position and size between sessions. If `true`, the application restores the previous window state on launch, enhancing user continuity.
## Window Colors `windowColors`
The `windowColors` property allows you to define default colors for the application window based on the operating system’s theme.
### `dark`
The `dark` field specifies the window color when the OS is in **dark mode**. This ensures that the application visually matches the user’s system theme and maintains readability and aesthetic consistency.
### `light`
The `light` field defines the window color when the OS is in **light mode**. Using this color ensures that the window blends seamlessly with the system’s light theme, providing a cohesive user experience.
## External Links `externalLinks`
The `externalLinks` property controls how links that lead outside the application are handled.
### `shouldOpenNonAppLinksExternally`
The `shouldOpenNonAppLinksExternally` field, when set to `true`, ensures that any link not part of the Native Desktop application opens in the user’s default web browser instead of within the app window. This prevents unexpected navigation inside the application and maintains a clear separation between internal and external content.
## HTML Pages `htmlPages`
The `htmlPages` property defines custom HTML pages that the application can display in specific states.
Each file path should be defined as an array of folder names ending with the file name, for example: `['folder', 'sub-folder', 'splash.html']`.
For each HTML page used by the application, **specific file names are recognized automatically**. If the HTML files match these names, Native Desktop will identify and use them correctly without additional configuration. The recognized files are:
* `splash-screen.html`: used for the loading state of the application.
* `not-allowed.html`: displayed when a requested page cannot be loaded or is not allowed.
* `offline.html`: shown when the application is offline or cannot access the internet.
Using these specific file names ensures that the application correctly handles different runtime states automatically.
### `splashScreen`
The `splashScreen` field specifies the HTML page shown during the **loading state** of the application. These page appear while the main content is initializing, providing visual feedback to the user.
### `offline`
The `offline` field defines the HTML page displayed when the application detects **no internet connection**. This allows you to show a user-friendly offline message or interface. File path follow the same array structure as other HTML pages.
### `httpNotAllowed`
The `httpNotAllowed` field specifies the HTML page shown when a requested page **cannot be loaded**. This ensures users receive clear feedback when navigation fails. File path must also be defined as arrays of folder names ending with the file name.
## Plugins `plugins`
The `plugins` field is a string path array that allows you to define custom plugins for your application.
Each entry must point to the **compiled JavaScript file**, not the original TypeScript source. For example, if your plugin source is located at `/src/plugin.ts` and it compiles to `runtime/plugin.js`, you should set the path as:
```json theme={null}
[
['runtime'], ['plugin.js'] // Path is runtime/plugin.js
]
```
This ensures that the Native Desktop framework loads the correct runtime files for your plugins.
## Renderer Plugins `rendererPlugins`
The `prendererPlugins` field is a string path array that allows you to define custom renderer plugins for your application.
Each entry must point to the **compiled JavaScript file**, not the original TypeScript source. For example, if your plugin source is located at `/src/rendererPlugin.ts` and it compiles to `runtime/rendererPlugin.js`, you should set the path as:
```json theme={null}
[
['runtime'], ['rendererPlugin.js'] // Path is runtime/rendererPlugin.js
]
```
This ensures that the Native Desktop framework loads the correct runtime files for your plugins.
## Development `development`
The `development` field provides options specifically for **development mode**.
### `shouldOpenDevToolsWhenRun`
The `shouldOpenDevToolsWhenRun` property, when set to `true`, automatically opens the browser or Electron **developer tools** each time the application starts. This is useful for debugging, inspecting elements, and monitoring console output during development. It should generally be disabled in production builds to prevent exposing developer tools to end users.
## HighRisk `highRisk`
The `highRisk` field contains settings that can impact application security and stability.
These options should be used **with caution** and are generally intended for advanced scenarios or trusted environments.
### `shouldLoadHTTPDomains`
The `shouldLoadHTTPDomains` property, when set to `true`, allows the application to load content over **insecure HTTP** connections. This can be useful for testing or internal sites but may expose users to security risks.
### `shouldEnableWebSecurity`
The `shouldEnableWebSecurity` property controls the browser’s security policies. If set to `false`, standard web security restrictions (such as same-origin policy) are disabled, which can be useful for development but is unsafe for production.
### `shouldAllowRunningInsecureContent`
The `shouldAllowRunningInsecureContent` property permits the execution of **mixed content**, such as scripts or resources loaded over HTTP within an HTTPS page. Enabling this can compromise security, so it should only be used in controlled environments.
### `shouldEnableExperimentalFeatures`
The `shouldEnableExperimentalFeatures` property activates **experimental Electron / browser features** that may not be stable or fully supported. This allows testing of new APIs but may introduce unpredictable behavior in the application.
# Native Desktop Framework
Source: https://docs.nativedesktop.com/native-desktop/user-guide/native-desktop-framework/introduction
The **Native Desktop Framework** is published on npm as the `@native-desktop/app` package. You do not need to install it manually, the **Native Desktop CLI** automatically manages all setup and operations related to this package.
The framework consists of three main components:
1. **Configuration File**: Defines project structure, runtime settings, and build behavior.
2. **Plugin System**: Extends core functionality with custom logic, integrations, and runtime hooks.
3. **IPC Commands**: Inter-Process Communication (IPC) commands refer to the methods and events used to facilitate communication between the main process and renderer processes. Electron's architecture separates the application's backend logic (main process) from its user interface (renderer processes), and IPC provides the necessary mechanism for these processes to interact.
These components work together to provide a flexible and maintainable environment for building Native Desktop-based desktop applications.
# IPC Commands
Source: https://docs.nativedesktop.com/native-desktop/user-guide/native-desktop-framework/ipc-commands
In Electron, Inter-Process Communication (IPC) is crucial for enabling communication between the main process and renderer processes. This is because they operate in separate environments with different responsibilities.
Native Desktop provides a set of **built-in IPC channels** for interacting with the desktop application. These IPCs allow you to get or set various aspects of the application and its environment.
* `nativeDesktopVersion`: Retrieve version information of the Native Desktop framework.
* `nativeDesktopApp`: Get or set application-specific details.
* `nativeDesktopWindow`: Get or set properties of the application window.
* `nativeDesktopNavigation`: Get or set navigation-related details within the app.
* `nativeDesktopNotification`: Set notification messages and properties.
* `nativeDesktopNetwork`: Set network-related configurations and behaviors.
The details for each IPC are explained in the following section:
# Main Plugins
Source: https://docs.nativedesktop.com/native-desktop/user-guide/native-desktop-framework/main-plugins
**Main plugins** allow you to customize, extend, or enhance the **main process** of the Native Desktop application. These plugins have full access to the **Electron API**, enabling you to add new capabilities or modify existing behavior. Each main plugin must follow a specific structure:
```typescript theme={null}
import { App } from 'electron';
const plugin = {
init: (nativeDesktopApp: App) => {
// Your main process logic here
},
};
export default plugin;
```
When the file follows this structure, Native Desktop will automatically **identify and inject the plugin** into the main process. There is no limit to the number of plugins you can create.
**Main plugins** operate on the **backend side** of the Native Desktop application and run within the main process. They **do not have direct access to the web view**.
To interact with the frontend or web view, you must create **renderer plugins**, which are specifically designed for the renderer proces
Here is a sample main plugin example. In this example, a new window is created whenever the main window is initialized:
```typescript theme={null}
import { BrowserWindow, App } from 'electron';
const plugin = {
init: (nativeDesktopApp: App) => {
nativeDesktopApp.whenReady().then(() => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
show: true,
});
mainWindow.loadURL('data:text/html;charset=utf-8,' +
encodeURIComponent('Hello from Main Plugin!
This window was created by your plugin.
')
);
mainWindow.webContents.openDevTools();
console.log('Window created and visible.');
});
nativeDesktopApp.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
nativeDesktopApp.quit();
}
});
},
};
export default plugin;
```
This approach allows developers to extend the core Native Desktop functionality safely and efficiently.
# Renderer Plugins
Source: https://docs.nativedesktop.com/native-desktop/user-guide/native-desktop-framework/renderer-plugins
**Renderer plugins** are used to interact with the **web view or frontend** of your Native Desktop application. They also support **Electron APIs**, allowing you to add new functionality or modify existing behavior in the renderer process. Each renderer plugin must follow a specific structure:
```typescript theme={null}
import type { IpcRenderer } from 'electron';
const plugin = {
init: (nativeDesktopIpcRenderer: IpcRenderer) => {
// Your renderer logic here
},
};
export default plugin;
```
When a file follows this structure, Native Desktop automatically **detects and injects the plugin** into the renderer process.
Here is a simple example demonstrating a console log. When the application runs, the message will appear in the web browser console:
```typescript theme={null}
import type { IpcRenderer } from 'electron';
const plugin = {
init: (nativeDesktopIpcRenderer: IpcRenderer) => {
console.log('Renderer plugin initialized:', nativeDesktopIpcRenderer);
},
};
export default plugin;
```
This structure allows developers to safely extend and customize frontend behavior while maintaining integration with Electron.
# React Components
Source: https://docs.nativedesktop.com/native-desktop/user-guide/react-components/introduction
React components in Native Desktop are not tightly coupled with the core framework but are designed to help you **customize and enhance your application's user interface**.
At the moment, the **Title Bar component** is the only available component, allowing you to create a **custom, theme-friendly title bar** that seamlessly matches your application's design and branding.
# Install Package
To use Native Desktop React components, first install the package using npm:
```shellscript theme={null}
npm install @native-desktop/react
```
After installation, you can import and use the components in your React application:
```typescript theme={null}
import { NativeDesktopTitleBar } from '@native-desktop/react';
const CustomTitleBar = () => {
return ;
}
```
# Title Bar Component
Source: https://docs.nativedesktop.com/native-desktop/user-guide/react-components/title-bar
The `NativeDesktopTitleBar` component provides a fully customizable, draggable title bar designed for **Electron-based Native Desktop applications**. It allows developers to replace the default OS title bar with a **custom React-driven UI**, giving full control over layout, styling, and interactivity.
# Overview
`NativeDesktopTitleBar` is a React component that renders a flexible container at the top of the application window. It supports **custom alignment**, **dynamic visibility**, and **drag regions** that integrate with Electron’s window controls (e.g., drag, maximize, unmaximize). It does **not rely on any external CSS files**, all styles are inline and customizable via props.
## Key Features
* **Draggable region** support using `WebkitAppRegion` for Electron windows.
* **Fully customizable layout** via `contentAlignment`, padding, height, and inline styles.
* **Composable components array**, render any React elements (buttons, titles, icons, menus, etc.) inside the title bar.
* **Visibility control** for both the entire title bar and individual components.
* **Double-click maximize/unmaximize** behavior, mimicking native window behavior.
## Usage Example
```typescript theme={null}
import { NativeDesktopTitleBar, ContentAlignment } from '@native-desktop/react';
import { MyWindowControls } from './MyWindowControls';
import { AppLogo } from './AppLogo';
export const MyAppTitleBar = () => (
,
isDragable: false,
},
{
id: 'right',
component: ,
isDragable: false,
},
]}
/>
);
```
# Titlebar Component
## Props
| Prop | Type | Default | Description |
| :----------------- | :------------------ | :-------------- | :------------------------------------------------------------------- |
| `id` | `string` | — | Optional ID for the title bar. |
| `components` | `TComponent[]` | `[]` | Array of components (React elements) to render inside the title bar. |
| `contentAlignment` | `TContentAlignment` | `SPACE_BETWEEN` | Determines how components are aligned within the container. |
| `height` | `number` | `32` | Height of the title bar in pixels. |
| `inlinePadding` | `number` | `8` | Horizontal padding (left and right). |
| `blockPadding` | `number` | `0` | Vertical padding (top and bottom). |
| `className` | `string` | `''` | Optional custom class name. |
| `style` | `CSSProperties` | `{}` | Inline style overrides for the container. |
| `isDragable` | `boolean` | `true` | Enables dragging of the entire title bar area. |
| `isVisible` | `boolean` | `true` | Controls visibility of the entire title bar. |
## Component Types
Each component object inside the `components` array defines what to render and how it behaves.
| Field | Type | Default | Description | |
| :----------- | :-------------- | :------------ | :------------------------------------------------- | ------------------------------------------------------- |
| `id` | \`string | number\` | — | Optional unique identifier. |
| `component` | \`ReactNode | JSX.Element\` | — | The React element to render (e.g., icon, button, text). |
| `className` | `string` | — | Optional class name for the wrapper div. | |
| `style` | `CSSProperties` | `{}` | Inline style for the wrapper div. | |
| `isDragable` | `boolean` | `true` | Whether this component region should be draggable. | |
| `isVisible` | `boolean` | `true` | Controls visibility of this specific component. | |
## Content Alignment Options
The `contentAlignment` prop controls horizontal positioning of child components.
| Alignment | CSS Equivalent | Description |
| :-------------- | :-------------- | :------------------------------------------------------- |
| `LEFT` | `flex-start` | Align items to the left. |
| `RIGHT` | `flex-end` | Align items to the right. |
| `CENTER` | `center` | Center all items horizontally. |
| `SPACE_BETWEEN` | `space-between` | Evenly distribute items, first at start and last at end. |
| `SPACE_AROUND` | `space-around` | Even spacing around all items. |
| `SPACE_EVENLY` | `space-evenly` | Equal spacing between and around all items. |
# Notes
* The title bar is rendered as a **fixed element** positioned at the top of the viewport.
* The container has a default background color of **red** — intended for debugging. You should override it using the `style` prop.
* For best results, combine with Electron’s frameless window mode.
# Developer Notes
## Design Philosophy
* The component is **style-agnostic**, no CSS or theme dependency.
* Built for **Electron environments only**, where frameless windows require custom drag and control logic.
* Uses **flexbox layout** for predictable alignment and composability.
## Drag Region Behavior
* Setting `WebkitAppRegion: drag` makes an area draggable by Native Desktop.
* **MacOS and Windows handle drag regions slightly differently**:
* On **macOS**, buttons near the top-left may interfere with draggable areas; ensure custom buttons are within `no-drag` zones.
* On **Windows**, draggable areas may overlap invisible hitboxes if padding or overlapping elements are misaligned.
Always mark interactive elements (buttons, menus) as `isDragable: false`.
## Window Events
* Double-clicking toggles maximize/unmaximize via `window.nativeDesktopWindow`.
* Developers can disable this behavior by removing or replacing the event listener.
## Performance & Rendering
* The component uses **inline styles** to avoid runtime stylesheet loading.
* Recommended for small, lightweight render trees (\<10 child components).
* Since it’s fixed-positioned, it won’t reflow with other layout changes.
## Accessibility
* The component itself doesn’t handle focus, keyboard navigation, or ARIA roles yet.
* If accessibility is a priority, wrap internal components (like buttons or menus) with proper roles and keyboard handlers.