Skip to main content
The Browser class is not directly accessible in the codebase - Flow Browser uses specialized controllers for managing windows, profiles, and tabs. The main entry point coordinates these controllers to provide a unified browser experience.

Architecture Overview

Flow Browser is built on Electron and uses a modular controller architecture:
  • Windows Controller: Manages browser windows and UI
  • Profiles Controller: Handles user profiles and sessions
  • Tabs Controller: Manages tab lifecycle, layout, and state
  • Spaces Controller: Organizes tabs into workspaces

Core Controllers

browserWindowsController

Manages browser window creation and lifecycle.
import { browserWindowsController } from '@/controllers/windows-controller/interfaces/browser';

// Create a new window
const window = await browserWindowsController.create('normal', {
  width: 1280,
  height: 720
});

// Get focused window
const focusedWindow = browserWindowsController.getFocusedWindow();

// Get all windows
const windows = browserWindowsController.getWindows();

Methods

create
(type, options) => Promise<BrowserWindow>
Creates a new browser windowParameters:
  • type: 'normal' | 'popup' - Window type
  • options: Window creation options (width, height, x, y)
Returns: Promise that resolves to the created BrowserWindow
instantCreate
(type, options) => BrowserWindow
Creates a window without waiting for Electron to be ready. Only use if Electron is already initialized.
getWindows
() => BrowserWindow[]
Returns all browser windows
getFocusedWindow
() => BrowserWindow | undefined
Returns the currently focused window
getWindowById
(id: number) => BrowserWindow | undefined
Retrieves a window by its ID
getWindowFromWebContents
(webContents: WebContents) => BrowserWindow | null
Finds a window from its WebContents instance
destroyAll
(force?: boolean) => void
Destroys all browser windowsParameters:
  • force: Whether to force destroy (default: false)

loadedProfilesController

Manages loaded user profiles and their sessions.
import { loadedProfilesController } from '@/controllers/loaded-profiles-controller';

// Load a profile
await loadedProfilesController.load('profile-id');

// Get loaded profile
const profile = loadedProfilesController.get('profile-id');

// Get all loaded profiles
const profiles = loadedProfilesController.getAll();

Methods

load
(profileId: string) => Promise<boolean>
Loads a profile and its session. Returns true if successful.
get
(profileId: string) => LoadedProfile | undefined
Retrieves a loaded profile by ID
getAll
() => LoadedProfile[]
Returns all loaded profiles
unload
(profileId: string) => boolean
Unloads a profile and destroys its tabs

tabsController

Manages tab creation, lifecycle, and state.
import { tabsController } from '@/controllers/tabs-controller';

// Create a new tab
const tab = await tabsController.createTab(windowId, profileId, spaceId);

// Get tab by ID
const tab = tabsController.getTabById(tabId);

// Set active tab
tabsController.setActiveTab(tab);

Methods

createTab
(windowId?, profileId?, spaceId?, options?) => Promise<Tab>
Creates a new tab. If parameters are omitted, uses focused window and last used space.Parameters:
  • windowId: Window to create tab in (optional)
  • profileId: Profile for the tab (optional)
  • spaceId: Space to assign tab to (optional)
  • webContentsViewOptions: Electron WebContentsView options (optional)
  • tabCreationOptions: Additional tab options (optional)
getTabById
(tabId: number) => Tab | undefined
Retrieves a tab by its ID
getTabByWebContents
(webContents: WebContents) => Tab | undefined
Finds a tab from its WebContents
setActiveTab
(tab: Tab) => void
Sets the active tab for its window and space
getTabsInWindow
(windowId: number) => Tab[]
Returns all tabs in a window
getTabsInProfile
(profileId: string) => Tab[]
Returns all tabs in a profile

Events

Controllers emit TypedEventEmitter events that you can listen to:
loadedProfilesController.on('profile-loaded', (profileId) => {
  console.log(`Profile ${profileId} loaded`);
});

tabsController.on('tab-created', (tab) => {
  console.log(`Tab ${tab.id} created`);
});

Example: Creating a Complete Browser Session

import { browserWindowsController } from '@/controllers/windows-controller/interfaces/browser';
import { loadedProfilesController } from '@/controllers/loaded-profiles-controller';
import { tabsController } from '@/controllers/tabs-controller';

// Create a window
const window = await browserWindowsController.create('normal');

// Load a profile
await loadedProfilesController.load('default');

// Create a tab
const tab = await tabsController.createTab(
  window.id,
  'default',
  'main-space',
  undefined,
  { url: 'https://example.com' }
);

// Set as active
tabsController.setActiveTab(tab);

Tab

Learn about the Tab class

Window

Learn about BrowserWindow

Profile

Learn about LoadedProfile

Build docs developers (and LLMs) love