# How to Persist FDC3 App-Channel State Using Window Context During Layout Save and Restore

**URL:** <https://community.interop.io/t/how-to-persist-fdc3-app-channel-state-using-window-context-during-layout-save-and-restore/546>\
**Category:** io.Connect Browser\
**Tags:** FDC3, layouts\
**Created:** [April 6, 2026, 12:02pm UTC](https://community.interop.io/t/how-to-persist-fdc3-app-channel-state-using-window-context-during-layout-save-and-restore/546 "2026-04-06T12:02:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [April 6, 2026, 12:02pm UTC](https://community.interop.io/t/how-to-persist-fdc3-app-channel-state-using-window-context-during-layout-save-and-restore/546/1 "2026-04-06T12:02:21Z")

</div>

## Background

This article covers two related issues that came up together in practice: a Workspaces restore bug that affected channel restoration (fixed in io.Connect Browser 4.1), and the broader question of how to persist FDC3 app-channel data across layout save/restore, which is application-managed by design.

## The Problem

When using FDC3 app channels in io.Connect Browser e.g. for broadcasting context via `fdc3.getOrCreateChannel('myChannel')` - the channel subscription and context data work as expected at runtime. However, when you save a layout and later restore it, the FDC3 app-channel data is not automatically restored with it.

## How User Channels and App Channels Differ on Layout Restore

**FDC3 User Channels** are predefined channels within the platform. They can be joined programmatically or through the UI. in io.Connect Browser 4.1 and later, apps should rejoin the last selected user channel automatically when the layout is restored. However, because user channels are shared across the entire io.Connect Browser ecosystem, the **d** ata within them is not saved or restored - only the channel membership is retained. This avoids interfering with other applications’ workflows.

**FDC3 App Channels** are created dynamically and are not predefined like user channels. They are implemented using the io.Connect Browser Shared Contexts API. Unlike user channels, app channels cannot be joined in the traditional sense, and they are not persisted by the platform when saving layouts.

Regardless of which channel type you use, the platform will **not** populate any context data when restoring a layout.

## The Solution: App-Managed Persistence via `onSaveRequested` and Window Context

Since the platform does not automatically persist app-channel state, the recommended approach is to save whatever you need into the window context and restore it in your own app logic.

You can do this using the [`onSaveRequested`](https://docs.interop.io/browser/capabilities/windows/layouts/layouts-api/index.html#save__update_context) hook from the Layouts API.

### Step 1: Save the App-Channel Data on Layout Save

Subscribe in the workspace window to save the app channel name and context when the layout is saved. Note that the callback must be synchronous.

```auto
const unsub = await io.layouts.onSaveRequested(() => {
  return {
    windowContext: { 
      appChannelName: "myChannel",
      appChannelContext: { test: 42 }
    }
  };
});

```

### Step 2: Retrieve the Saved Data on Layout Restore

When the layout is restored, retrieve the window context:

```auto
const myWindow = io.windows.my();
const myContext = await myWindow.getContext();
/*
{
  "appChannelName": "myChannel",
  "appChannelContext": { "test": 42 }
}
*/

```

You can also subscribe for context updates via [`onContextUpdated`](https://docs.interop.io/browser/reference/javascript/windows/index.html#WebWindow-onContextUpdated).

### Step 3: Save and restore context

With this approach, you can:

1. Use `onSaveRequested` to store your current app channel and context into the window context during layout save.

2. On app initialization (after layout restore), consume the window context and implement your logic — for example, re-create the channel and broadcast the saved context.

## Summary

### Window Context:

The _data associated with a single window instance_ inside the layout. Each window can have its own context, and it may be _any object_. Apps consume this using `[io.windows.my](http://io.windows.my/ "http://io.windows.my")().getContext()`.

### FDC3 Context:

A standardized data format defined by the [FDC3 spec](https://fdc3.finos.org/docs/context/spec), used for passing business identifiers (e.g., instrument, contact, organization) between apps. All FDC3 contexts require a `type` property (e.g., `“fdc3.instrument”`).

Any type of object may be saved as a layout or a window context.

- To save a window context into a layout, use the [onSaveRequested](https://docs.interop.io/browser/capabilities/windows/layouts/layouts-api/index.html#save__update_context) hook.

- For obtaining a window context, call [getContext](https://docs.interop.io/browser/reference/javascript/windows/index.html#WebWindow-getContext) or subscribe for updates via [onContextUpdated](https://docs.interop.io/browser/reference/javascript/windows/index.html#WebWindow-onContextUpdated)

> A bug in the Workspaces library caused `io.workspaces.restoreWorkspace()` to fail to restore even user-channel associations correctly. This was fixed in io.Connect Browser 4.1, so if you face it update your version.

## Related Documentation

- [Layouts API — Save & Update Context](https://docs.interop.io/browser/capabilities/windows/layouts/layouts-api/index.html#save__update_context)

- [Window `getContext` Reference](https://docs.interop.io/browser/reference/javascript/windows/index.html#WebWindow-getContext)

- [Window `onContextUpdated` Reference](https://docs.interop.io/browser/reference/javascript/windows/index.html#WebWindow-onContextUpdated)

- [FDC3 Compliance — Channels](https://docs.interop.io/browser/getting-started/fdc3-compliance/index.html#channels)
