# \[Code template\] Platform initialization with layout restore

**URL:** <https://community.interop.io/t/code-template-platform-initialization-with-layout-restore/608>\
**Category:** io.Connect Desktop\
**Tags:** starter-code, JavaScript\
**Created:** [June 23, 2026, 4:59pm UTC](https://community.interop.io/t/code-template-platform-initialization-with-layout-restore/608 "2026-06-23T16:59:16Z")\
**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:** [June 23, 2026, 4:59pm UTC](https://community.interop.io/t/code-template-platform-initialization-with-layout-restore/608/1 "2026-06-23T16:59:16Z")

</div>

> This is a small, self-contained snippet you can adapt to test io.Connect integration patterns or reproduce issues without sharing proprietary code.

**[All code templates](https://community.interop.io/tag/starter-code) | [Why we’re publishing these](https://community.interop.io/t/templates-to-help-troubleshooting-and-support/592)**

```javascript
import IOConnectFactory from "@interopio/desktop";
import * as WorkspacesFactory from "@interopio/workspaces-api";
import * as os from "os";

export const setupGlue = async () => {
    const glue = await IOConnectFactory({
        libraries: [WorkspacesFactory.default],
        layouts: "full",
        application: "clientlist", // replace with your app name
        channels: true,
        auth: {
            username: os.userInfo().username,
            password: "",
        },
        gateway: {
            ws: process.env.IO_CD_GATEWAY ?? "ws://0.0.0.0:8385",
        },
    });

    console.log("Glue initialized");

    glue.layouts.onRestored(async () => {
        console.log("Layout restored");
        // your post-restore logic here
    });

    return glue;
};

(async () => {
    const glue = await setupGlue();
    console.log("Restoring layout...");
    await glue.layouts.restore({ name: "workspaces-test" }); // replace with your layout name
    console.log("Starting app...");
    await glue.appManager.application("clientlist").start({}, {}); // replace with your app name
    console.log("Done");
})();

```

The `layouts.onRestored` handler fires after a layout is restored, and if you do heavy async processing inside it (e.g. fetching data, waiting on services, reinitializing state), the platform waits for it to complete. If it takes too long, subsequent calls like `app.start` can internally timeout. If you’re seeing unexpected timeout errors during startup, this template can help you isolate whether it’s the async work in your `onRestored` handler causing the delay.
