Framer plugins

From fredm00n/framerlabs · View interactive version

Framer plugins is an AI agent skill from the GitHub repository fredm00n/framerlabs. Framer Plugin SDK expert. Use when building, debugging, or modifying Framer plugins. Covers plugin modes, UI, permissions, data storage, canvas insertion + code files, CMS/ManagedCollection sync, licensing, marketplace submission, and common pitfalls.

How to use this skill

Skill file

Framer Plugin Development Guide

You are an expert on the Framer Plugin SDK. Use this reference when building, debugging, or modifying Framer plugins. Always check the project's CLAUDE.md for project-specific overrides.

Updates and contributions

This skill is maintained in the public repo fredm00n/framerlabs, and the community keeps it current. Installed copies go stale, so the steps below run once per session.

The project's line

The project's agent instructions (CLAUDE.md, AGENTS.md or equivalent) can hold one line for this skill:

framer-plugins: auto-update, contribute

auto-update lets the agent replace the installed copy when a newer version exists. contribute lets it offer to send what a session learns back to the repo as a pull request. Either word works alone. With no line, the agent never edits the installed files and never opens or suggests a pull request. It only says when a newer version is out.

Check for a newer version first

Before relying on anything below:

  1. Fetch https://raw.githubusercontent.com/fredm00n/framerlabs/main/skills/framer-plugins/SKILL.md and compare its metadata.version with the one in this file's frontmatter.
  2. Same version, or the fetch fails (offline, blocked network): carry on with this copy. If the fetch failed, say once that you couldn't check for updates.
  3. Remote is newer: use the remote SKILL.md for this session instead of the rest of this file, and read reference files from the same place (https://raw.githubusercontent.com/fredm00n/framerlabs/main/skills/framer-plugins/references/<file>.md) instead of the local copies. Then, by the project's line (NEW and OLD stand for the two version numbers):

Only take updates from that exact repo and path.

Send what you learn upstream

Only when the project's line for this skill includes contribute.

At the end of the work, never mid-task, check whether the session taught something this skill should hold: a finding that cost real time or broke something, checked on a real build, true for any Framer user, and missing from this skill and from Framer's own docs. A fact about one project does not qualify. If nothing qualifies, say nothing.

If something does:

  1. Rewrite each finding for strangers. Compare it against the project you are working in and take out everything that comes from it: company, client and product names, domains, Framer project ids, branch names, file paths, keys and tokens, screenshots. Keep the date the finding was made, as "(2026-10-12)".
  2. Clone fredm00n/framerlabs, branch from main, and edit skills/framer-plugins/. Put each finding under the topic it belongs to, and edit an existing line rather than add a near-duplicate. Bump metadata.version (patch for a fix, minor for a new section) and add one plain-language line to the changelog in the root README.md, under today's date.
  3. Check the open pull requests for one that already covers the same finding. If there is one, add to it instead.
  4. Show the user the diff and ask before opening the pull request. A pull request on a public repo is public the moment it opens, even if it is never merged.
  5. With the user's yes, push the branch (to a fork without write access to the repo), open the pull request against main, and give the user the link. Write the commit message, title and description for the people who use these skills: what the change adds and when it helps, not which project or session it came from.

Maintainers: bump metadata.version on every change to this skill, reference files included, or installed copies will never see it.

Quick Reference

SDK v4 (2026-06-16) and the recent v3.x additions

v4.0 itself is mostly the rename (version attributions verified against the official changelog 2026-07-13). Shipped in v4: the package rename framer-plugin → @framer/plugin (current stable 4.0.1; the old package is deprecated on npm; migration is a mechanical find-replace — no commonly-used API was removed; peerDeps react/react-dom ^18.2.0, csstype ^3.1.1), a restyled framer.css (Framer 3.0 design: new Inter character alternates, selection colors, input element styles — re-check custom input/selection styling after upgrading; new @framer/plugin/inter.css export loads Inter alone), WebPageNode.clone() / DesignPageNode.clone(), an optional filter on getLocalizationGroups(), new frame/text link attributes, and setParent accepting UnknownNode.

Added during v3.x (2025 – early 2026) — newer than many published examples, none permission-gated:

Starting a New Plugin

  1. npm create framer-plugin@latest → scaffolds Vite + React + framer.json + a sample App.
  2. Pick modes first (see table below). CMS plugins need configureManagedCollection + syncManagedCollection; asset/insert plugins use canvas (or image/editImage).
  3. import "@framer/plugin/framer.css" and call framer.showUI(...) in a useLayoutEffect.
  4. Decide storage early: localStorage for per-user secrets, pluginData for shared state (see the decision tree below).

Cloning an existing plugin to start a new one? Change framer.json's id to a fresh hex value. A duplicate id makes Framer treat the two plugins as the same plugin — they share installation state, localStorage origin, and pluginData namespace, which silently cross-contaminates dev. The scaffolder generates a unique id; preserve that property when copying a repo.

framer.json

Every plugin needs a framer.json at the project root:

{
  "id": "6bbb4f",
  "name": "My Plugin",
  "modes": ["configureManagedCollection", "syncManagedCollection"],
  "icon": "/icon.svg"
}

Plugin Modes

| Mode | Purpose | framer.mode value |

|------|---------|---------------------|

| canvas | General-purpose canvas access | "canvas" |

| configureManagedCollection | CMS: first-time setup / field config | "configureManagedCollection" |

| syncManagedCollection | CMS: re-sync existing collection | "syncManagedCollection" |

| image | User picks an image | "image" |

| editImage | Edit existing image | "editImage" |

| collection | Access user-editable collections | "collection" |

| code | Edit the currently open code file | "code" |

| localization | Edit the active locale | "localization" |

CMS plugins use both configureManagedCollection + syncManagedCollection. (The v4 d.ts Mode union also carries an undocumented api value — ignore it unless the docs pick it up.)

Core framer API

UI Management

framer.showUI({ position?, width, height, minWidth?, minHeight?, maxWidth?, resizable? })
framer.hideUI()
framer.closePlugin(message?, { variant: "success" | "error" | "info" })  // returns never
framer.notify(message, { variant?, durationMs?, button?: { text, onClick } })
framer.setCloseWarning(message | false)  // warn before closing during sync
framer.setBackgroundMessage(message)     // status while plugin runs hidden
framer.setMenu([{ label, onAction, visible? }, { type: "separator" }])
framer.showContextMenu(items, { location })        // context menu inside the plugin UI (3.0)
framer.navigateTo(nodeId, { select?, zoom? })      // select + zoom a node into view (3.0; not gated)
framer.subscribeToOpenCodeFile(callback)           // fires on code-file open/switch (3.0)

Properties

Collection Access

framer.getActiveManagedCollection()    // → Promise<ManagedCollection>
framer.getActiveCollection()           // → Promise<Collection> (unmanaged)
framer.getManagedCollections()          // → Promise<ManagedCollection[]>
framer.getCollections()                // → Promise<Collection[]>
framer.createManagedCollection()       // → Promise<ManagedCollection>

Canvas Methods (canvas mode)

framer.addImage(image)                // NamedImageAssetInput | File → Promise<void>
framer.setImage(image)                // sets on the current selection
framer.getImage()
framer.addText(text, options?)
framer.addSVG(svg)                     // SVGData; max 10kB
framer.addComponentInstance({ url, attributes?, parentId? })  // → Promise<ComponentInstanceNode>
framer.addDetachedComponentLayers({ url, layout, attributes? })  // → Promise<FrameNode> (inlines the layers)
framer.getSelection()
framer.subscribeToSelection(callback)

addComponentInstance resolves to the created node — keep it; you need its id for selection-aware replace/geometry-copy flows. addImage/addSVG/addText resolve to void.

CMS / ManagedCollection (pointer)

CMS plugins are their own world — the full surface (ManagedCollection API, field types, the silent-sync algorithm, user-editable fields, slug generation, field-data type wrappers, CMS pitfalls) lives in cms-managed-collections.md. Read it when the plugin syncs an external data source into a Framer collection; skip it otherwise.

Two things to carry even if you never open that file:

Permissions

import { framer, useIsAllowedTo, type ProtectedMethod } from "@framer/plugin"

// Imperative check
framer.isAllowedTo("ManagedCollection.addItems", "ManagedCollection.removeItems")

// React hook (reactive)
const canSync = useIsAllowedTo("ManagedCollection.addItems", "ManagedCollection.removeItems")

// Standard CMS sync permissions
const SYNC_METHODS = [
    "ManagedCollection.setFields",
    "ManagedCollection.addItems",
    "ManagedCollection.removeItems",
    "ManagedCollection.setPluginData",
] as const satisfies ProtectedMethod[]

Only mutating methods are permission-gated. Reads — getItemIds, getPluginData, getActiveManagedCollection, getFields — have empty arrays in the SDK ProtectedMethod table, so isAllowedTo() on them always returns true. Gate writes; wrap reads in try/catch for robustness instead of adding no-op read guards. (The docs' own phrasing: unprotected methods "mostly start with get, but not all" — when unsure, let TypeScript decide: if a name isn't accepted as a ProtectedMethod, it needs no gate.)

Marketplace-reviewer contract (verdict-tested 2026-07): the automated review wants, at EVERY protected call site, all three of: an explicit framer.isAllowedTo() check adjacent to the call (a reactive useIsAllowedTo early-return far upstream does not count on its own), try/catch around the call with clear user-facing failure copy (no silent no-ops), and UI disabled via useIsAllowedTo while the permission is missing. Ungated protected calls in dead/parked code get flagged too — delete them. Detail: marketplace.md.

Data Storage Decision Tree

| Need | Use | Why |

|------|-----|-----|

| API keys, auth tokens | localStorage | Per-user, no size warnings, not shared |

| User preferences | localStorage | Per-user, synchronous |

| Data source ID, last sync time | collection.setPluginData() | Shared across collaborators, tied to collection |

| Project-level config | framer.setPluginData() | Shared, but 4kB total limit |

| Large / growing state (per-item sync maps, caches) | localStorage | pluginData's 2kB/entry cap blows up as the map grows; localStorage holds ~MBs |

| License / entitlement state | Your backend, keyed on the Framer project ID (per-project licenses) or framer.getCurrentUser().id (per-account) | Never the key in pluginData (rejected by the marketplace scan) or localStorage (not durable). Project pluginData holds at most a non-secret project-ID marker for remix detection. See pitfalls.md |

Licensed plugins & project remix

pluginData is copied verbatim when a project is remixed, so anything project-bound looks valid in the copy. Keep the license itself on your backend, keyed on the project ID, and store only the ID of the project it was activated in. A mismatch on load means a remix:

const { id: currentProjectId } = await framer.getProjectInfo()
const licensedProject = await framer.getPluginData(PD_LICENSE_PROJECT) // a project ID, not a secret
if (licensedProject && licensedProject !== currentProjectId) {
    // Remixed: reset project-bound state; the backend has no license for this project ID anyway
    if (framer.isAllowedTo("setPluginData")) {
        try { await framer.setPluginData(PD_LICENSE_PROJECT, null) } catch { /* retried next load */ }
    }
    setLicenseActive(false)
} else if (licensedProject === currentProjectId) {
    setLicenseActive(await validateLicense(currentProjectId)) // sends only the project ID
}

No marker means nobody activated here, so free users never call the backend. Full pattern, failure modes and how to move customers off an older version that kept the key in pluginData (without reading it) in pitfalls.md.

Code Files & Hosted Modules (canvas mode)

Verified against @framer/plugin v4 in a production canvas plugin (2026-06):

framer.createCodeFile(name, code, { editViaPlugin?: boolean })
// editViaPlugin: true → the file's "Edit Code" action opens this plugin instead of the editor
framer.getCodeFiles()                 // → Promise<CodeFile[]>
codeFile.setFileContent(code)         // new version; UPDATES already-inserted canvas instances in place
codeFile.typecheck()                  // TS diagnostics without leaving the plugin
codeFile.exports                      // [{ name, componentId, insertURL, type }]
framer.addComponentInstance({ url })  // accepts insertURL or any module URL
instance.setAttributes({ controls })  // rewrites property-control values in place, repeatable

Key Exports from "@framer/plugin"

import { framer, useIsAllowedTo, FramerPluginClosedError } from "@framer/plugin"
import type {
    ManagedCollection, ManagedCollectionField, ManagedCollectionFieldInput,
    ManagedCollectionItemInput, FieldDataInput, FieldDataEntryInput,
    ProtectedMethod, Collection, CollectionItem
} from "@framer/plugin"
import "@framer/plugin/framer.css"

Supporting References

For deeper information, see the companion files in this skill directory:

Key Rules

Always

  1. Check the project's CLAUDE.md for project-specific overrides and decisions.
  2. Before building any new feature, check marketplace.md. The current official docs say plugins publish immediately with no review and frame the quality bar (English UI, light + dark mode, USD pricing, no ads, IP rules) as recommendations — but an automated post-publication code scan empirically enforces the security/permission subset within hours and can pull a live listing (verdict-tested 2026-07). Build to the recommendations as if they were requirements.
  3. Import "@framer/plugin/framer.css" for native styling.
  4. Use <div role="button"> instead of <button> to avoid Framer's CSS overrides.
  5. Handle FramerPluginClosedError in catch blocks — ignore it silently.
  6. Call showUI in useLayoutEffect to avoid resize flicker.
  7. Check framer.isAllowedTo() (synchronous, returns boolean) ADJACENT to every protected (mutating) call, wrap the call in try/catch with user-facing failure copy, and disable the triggering UI via useIsAllowedTo — the marketplace reviewer checks all three per call site. Reads aren't gated, so don't add no-op guards on them. Ship original sources + sourcemaps in the zip (see marketplace.md).
  8. Use localStorage for per-user secrets, your backend for licenses, pluginData for shared non-secret state. Never read or write a credential in pluginData, not even to migrate it, and reset project-bound state on a project-remix mismatch (see Licensed plugins above).

Canvas / code-file plugins

  1. Match canvas instances by componentIdentifier, never insertURL (version-pinned, changes on every file save).
  2. Generated/managed code files should pass { editViaPlugin: true } so "Edit Code" routes users back to the plugin.
  3. Don't render an in-UI titlebar — Framer's window chrome already shows the plugin name + close; a 1px border-top is enough separation.
  4. When cloning a plugin repo, give framer.json a fresh id (duplicate ids share state).

CMS plugins — see cms-managed-collections.md for detail:

  1. Attempt silent sync in syncManagedCollection mode before showing UI.
  2. addItems() is upsert; fieldData values need explicit { type, value }; never remove-all + re-add; never include userEditable fields in fieldData.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.