本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Electron ドキュメント
Electron
Getting Started with ElectronProject StructureCore ConceptsData and StateTestingDeployment
ディスカッション

Electron ガイド · 4/6

Data and State

この章は現在、英語でのみ提供しています。

Desktop apps keep data on the user's machine: settings, recent files, and documents. This chapter covers where to store data, native APIs such as file dialogs and notifications, and how to split state between renderers and the main process.

App data paths

Each operating system keeps app data in a different place; app.getPath() returns the right directory. App-specific data belongs in userData.

NamePurpose
userDataApp settings and data; by default a folder named after the app
documentsThe user's documents folder
downloadsThe downloads folder
tempTemporary files
logsThe app's log folder
const { app } = require('electron')

app.whenReady().then(() => {
  console.log(app.getPath('userData'))
  // Windows: C:\Users\<user>\AppData\Roaming\<app name>
  // macOS: ~/Library/Application Support/<app name>
  // Linux: ~/.config/<app name>
})

Never write user data next to the app itself (app.getAppPath() or the executable folder). After packaging, that location may be read-only or replaced on update.

Saving settings to a file

A single JSON file is enough for small settings. Do the file access in the main process and give renderers only read and write operations over IPC. Writing to a temporary file and renaming it keeps the file intact if the app quits mid-write.

// main.js
const { app, ipcMain, BrowserWindow } = require('electron')
const fs = require('node:fs/promises')
const path = require('node:path')

const settingsFile = () => path.join(app.getPath('userData'), 'settings.json')
const defaults = { theme: 'system', recentFiles: [] }

async function loadSettings() {
  try {
    return { ...defaults, ...JSON.parse(await fs.readFile(settingsFile(), 'utf8')) }
  } catch {
    return { ...defaults }
  }
}

async function saveSettings(settings) {
  const tmp = `${settingsFile()}.tmp`
  await fs.writeFile(tmp, JSON.stringify(settings, null, 2))
  await fs.rename(tmp, settingsFile())
}

ipcMain.handle('settings:get', () => loadSettings())

ipcMain.handle('settings:setTheme', async (_event, theme) => {
  if (!['light', 'dark', 'system'].includes(theme)) throw new Error('invalid theme')
  const settings = { ...(await loadSettings()), theme }
  await saveSettings(settings)
  // Tell every open window about the change
  for (const win of BrowserWindow.getAllWindows()) win.webContents.send('settings:changed', settings)
  return settings
})

For a key-value store, consider the community package ; for larger data, an embedded database such as SQLite. Native modules like must be rebuilt against Electron, which Forge does for you (otherwise run ).

この章について質問がありますか?
前の章Core Concepts次の章Testing
electron-store
better-sqlite3
npx @electron/rebuild

File dialogs

The dialog module opens native dialogs: showOpenDialog, showSaveDialog, and showMessageBox for confirmations. Pass a window as the first argument to make the dialog modal to it.

const { dialog } = require('electron')

ipcMain.handle('file:save', async (event, content) => {
  if (typeof content !== 'string') throw new Error('invalid content')
  const win = BrowserWindow.fromWebContents(event.sender)
  const { canceled, filePath } = await dialog.showSaveDialog(win, {
    defaultPath: path.join(app.getPath('documents'), 'note.txt'),
    filters: [{ name: 'Text', extensions: ['txt', 'md'] }],
  })
  if (canceled || !filePath) return false
  await fs.writeFile(filePath, content, 'utf8')
  return true
})

Notifications and secure storage

Notification in the main process posts to the system notification center; renderers can also use the web Notification API. On Windows, notifications need an Application User Model ID; installers usually set it, and in development you can call app.setAppUserModelId().

Encrypt sensitive strings such as passwords or access tokens with safeStorage, which uses the operating system's key storage, before writing them to disk.

const { Notification, safeStorage } = require('electron')

function notifyDone(fileName) {
  if (Notification.isSupported()) {
    new Notification({ title: 'Export complete', body: `Saved ${fileName}.` }).show()
  }
}

async function saveToken(token) {
  if (!safeStorage.isEncryptionAvailable()) throw new Error('encryption unavailable')
  const encrypted = safeStorage.encryptString(token) // Buffer
  await fs.writeFile(path.join(app.getPath('userData'), 'token.bin'), encrypted)
}

async function loadToken() {
  const encrypted = await fs.readFile(path.join(app.getPath('userData'), 'token.bin'))
  return safeStorage.decryptString(encrypted)
}

State in the renderer

A renderer handles state like any web app. Keep UI state in your framework's state tools (React, Vue, Svelte, and so on), small values in localStorage, and larger data in IndexedDB. With the default session these stores live under userData, so they survive restarts.

When several windows must see the same data, make the main process the single source of truth. Renderers request values over IPC, and the main process broadcasts changes to every window.

// preload.js
contextBridge.exposeInMainWorld('settings', {
  get: () => ipcRenderer.invoke('settings:get'),
  setTheme: (theme) => ipcRenderer.invoke('settings:setTheme', theme),
  onChanged: (callback) => {
    ipcRenderer.on('settings:changed', (_event, value) => callback(value))
  },
})

// renderer.js
const apply = (settings) => { document.documentElement.dataset.theme = settings.theme }
window.settings.get().then(apply)
window.settings.onChanged(apply)

Summary

  • Store app data under app.getPath('userData'), never in the installation folder.
  • Access files in the main process and open only validated IPC handlers to renderers.
  • Use dialog, Notification, and safeStorage for dialogs, notifications, and encrypting sensitive values.
  • Keep UI state in the renderer and state shared across windows in the main process.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。