---
title: "Share context between your apps"
description: "Let apps of one owner on one machine share a person's language or progress, only with their yes, and see what flows with mainsdk context."
section: "guides"
status: "Building for 0.4"
spec: "context"
canonical: "https://mainsdk.dev/docs/guides/share-context-between-your-apps"
updated: "2026-10-28"
---

# Share context between your apps

> Let apps of one owner on one machine share a person's language or progress, only with their yes, and see what flows with mainsdk context.

Status: Building for 0.4 · Canonical: https://mainsdk.dev/docs/guides/share-context-between-your-apps · Updated: 2026-10-28

You will declare one purpose, ask for the person's consent, send a setting to a peer app and check what flowed. It takes about 10 minutes. Nothing leaves the machine unless you declare a sink.

## You need

- Two MainSDK apps of one owner on the same machine, mutual peers (`apps.registry: on`).

## 1. Declare the purpose

```yaml title="main.yaml"
context:
  group: acme-learning
  identity: first-party
  purposes:
    personalise:
      description: "Use the same language and theme in every Acme app"
      attributes: [locale, theme]
      retention: 30d
      share-with: [prj_01JD8X]
```

## 2. Ask, then share

```ts
import { app } from "mainsdk";

const ctx = app().sharedContext;
const user = { id: "u_123" };
await ctx.consent.set(user, "personalise", true);
await ctx.shared.put({ purpose: "personalise", attributes: { locale: "hi-IN" } }, { user });
```

A peer without its own yes drops the message and answers `held`.

## Check it worked

```text
mainsdk context
```

It prints the group, each purpose with its `share-with`, and how many people consented and how many flows went out and came in. `--json` gives the same for a tool. It never shows a context id, a user id or a value.
