Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Electron docs
Electron
Getting Started with ElectronProject StructureCore ConceptsData and StateTestingDeployment
Discussions

Electron guide · 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 electron-store; for larger data, an embedded database such as SQLite. Native modules like better-sqlite3 must be rebuilt against Electron, which Forge does for you (otherwise run 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.
Questions about this chapter?
Previous chapterCore ConceptsNext chapterTesting

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.