npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rokmohar/medusa-plugin-admin-layouts

v0.2.0

Published

Hide, move, reorder and replace core Medusa admin sections from code

Readme

Admin layouts plugin for Medusa

npm version npm downloads CI License: MIT

Hide, move, reorder and replace the core sections of Medusa admin pages from medusa-config.ts, so your admin layout is versioned with your code and the same on every environment.

Why

Medusa's admin extensions add new pages and widgets, but they can't change the pages Medusa ships. Since Medusa 2.22, admins can rearrange page sections in the browser and save the result for themselves or for everyone. That arrangement lives in the database: it doesn't travel from development to production, and any admin can undo it.

This plugin closes that gap. You declare the layout of a page in code, and the plugin serves it as the page's default layout for everyone.

What you get

  • Hide core sections and widgets, such as the order activity timeline or a sidebar menu item.
  • Move and reorder sections, also between the main and side columns.
  • Replace a core section with your own widget, in the exact spot the section had.
  • Lock hidden sections, so users can't show them again in their personal layout.
  • Export a layout you arranged in the admin as code, from the plugin's settings page.
  • Autocomplete and type checks: your editor suggests page names and the section ids of each page, and flags ids that don't exist on a page.
  • Validation at boot: an invalid config stops the server with a clear message, unknown ids are logged as warnings.
  • No database writes: layouts are applied per request, so a deploy changes them immediately.

Compatibility

| Plugin | Medusa | Node | | -------- | -------- | ---------- | | ~0.2.0 | 2.23.x | >= 22.12 | | ~0.1.0 | 2.22.x | >= 22.12 |

The plugin ships the section order of every admin page of one Medusa minor version, which replacing and reordering rely on. On a different minor version it logs a warning and its settings page shows one, because sections may land in the wrong place. Hiding works regardless.

Installation

npm install @rokmohar/medusa-plugin-admin-layouts
# or
yarn add @rokmohar/medusa-plugin-admin-layouts
# or
pnpm add @rokmohar/medusa-plugin-admin-layouts

Quick start

Add the plugin to medusa-config.ts and describe the pages you want to change:

import { defineConfig } from '@medusajs/framework/utils'
import { defineAdminLayouts } from '@rokmohar/medusa-plugin-admin-layouts'

module.exports = defineConfig({
  // ... other config
  plugins: [
    {
      resolve: '@rokmohar/medusa-plugin-admin-layouts',
      options: defineAdminLayouts({
        lock: true,
        zones: {
          'order.details': {
            hide: ['core:OrderActivitySection'],
            replace: { 'core:OrderSummarySection': 'widget:my-store:order-summary' },
            sections: { side: ['core:OrderCustomerSection', 'core:OrderGeneralSection'] },
          },
        },
      }),
    },
  ],
})

The replacing widget is a regular admin widget with an explicit id:

// src/admin/widgets/order-summary.tsx
import { defineWidgetConfig } from '@medusajs/admin-sdk'

const OrderSummary = () => {
  return <div>Your order summary</div>
}

export const config = defineWidgetConfig({
  zone: 'order.details.after',
  id: 'my-store:order-summary',
})

export default OrderSummary

Restart the server. On the order page the activity timeline is gone, your widget sits where the summary was, and the order header moved to the side column under the customer.

Configuration

defineAdminLayouts takes these options:

| Option | Type | Default | Description | | ------- | ---------------------------- | ------- | ---------------------------------------------------------------------------- | | lock | boolean | false | Keep hidden and replaced sections hidden in users' personal layouts. | | zones | Record<string, ZoneLayout> | {} | The layout of each page, keyed by zone. See Zones and ids. |

Each ZoneLayout takes:

| Option | Type | Description | | ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | hide | string[] | Sections and widgets to hide. | | replace | Record<string, string> | Core section → widget. The widget takes the section's spot and the section is hidden. | | sections | Record<string, string[]> | Layout section (main, side) → ids to show first, in this order. Listing an id under another section moves it there. The rest follow in their usual order. | | lock | boolean | Overrides the top-level lock for this zone. |

The config is validated when Medusa loads it. These stop the server at boot:

  • an id that doesn't start with core: or widget:
  • an id listed under two sections
  • one widget replacing two sections
  • replace on a page the plugin has no section order for (see Limitations)

In TypeScript, defineAdminLayouts knows the page names and section ids of the supported Medusa version: your editor suggests them, and an id that doesn't exist on a page is a type error. Pages the plugin doesn't know, such as the sidebars, accept any core: id. At runtime, ids or sections that the plugin doesn't know for a page are logged as warnings.

Zones and ids

  • Zone: a page, named like its widget zones without the position: order.details, product.list, customer.details, topbar, sidebar. Settings → Admin layouts lists all of them; turn on Show pages with Medusa's default layout to see pages you haven't changed.
  • Core section: core: followed by the section's id in the dashboard, e.g. core:OrderSummarySection. Click Sections next to a page in Settings → Admin layouts to see its ids in their current order, with a copy button for each. They are also in src/catalog/core-entries.ts. Most detail pages also have core:MetadataSection, core:JsonViewSection and core:RequiredPermissionsSection.
  • Widget: widget: followed by the id from defineWidgetConfig. Give every widget you place an explicit id, otherwise Medusa derives one from the file path and it changes when the file moves. Prefix ids with your project or plugin name to avoid collisions.

Recipes

Hide the JSON section on every product page:

zones: {
  'product.details': { hide: ['core:JsonViewSection'] },
}

Move a widget into the side column, above the customer:

zones: {
  'order.details': { sections: { side: ['widget:my-store:loyalty', 'core:OrderCustomerSection'] } },
}

Hide a menu item in the main sidebar:

zones: {
  sidebar: { hide: ['core:nav:/promotions'] },
}

Hide a section for everyone but let users show it again:

zones: {
  'customer.details': { hide: ['core:CustomerGroupSection'], lock: false },
}

Exporting a layout from the admin

Arranging a page by hand is often easier than writing the config:

  1. Open the page and arrange it with the layout customizer in the top bar, then choose Save for everyone.
  2. Open Settings → Admin layouts and click Copy as code next to the page, or Copy all as code. The copied code is formatted like Prettier formats medusa-config.ts with single quotes.
  3. Paste the copied zones into the plugin options.

Once a page is configured in code, changing its default layout with Save for everyone is rejected with a message that the layout is managed in code. Saving it unchanged still works and switches you to the default view. Personal layouts keep working.

How it works

The plugin adds a middleware to Medusa's layout endpoint, GET and POST /admin/layouts/:zone/configuration. For zones configured in code:

  • GET returns your layout as the zone's default layout, in the format the admin's layout composer reads. For locked zones, the sections you hid are also hidden in the user's personal layout.
  • POST rejects changes to the default layout. Saving the default unchanged, which is how the admin switches a user to the default view, only switches the view and stores nothing. For locked zones, your hidden sections stay hidden in a saved personal layout.

Other zones pass through untouched. The plugin also adds GET /admin/admin-layouts, which feeds its settings page.

To place a replacing widget or keep the rest of a section in order, the plugin uses a catalog of every page's sections, generated from the Medusa source of the supported version.

Limitations

  • Only whole sections can be changed. Content inside a section, core pages and their routes can't be replaced by a plugin.
  • A user's personal layout takes precedence over the default, as in Medusa. Locking keeps hidden sections hidden, but doesn't reset the order a user chose.
  • Widgets that aren't listed under sections appear at the top of their section, which is how Medusa treats entries without a saved position. List your widgets to place them.
  • The main and settings sidebars build their entries at runtime, so they aren't in the catalog. hide works there, replace doesn't, and sections should list every entry you want in a set order.

Troubleshooting

My widget doesn't show up where the replaced section was. Check that the widget's defineWidgetConfig has the same id as in replace, without the widget: prefix, and that it is registered in a zone of the same page, e.g. order.details.after.

The layout doesn't change for me. You are probably viewing your personal layout of that page. Open the layout customizer in the top bar, choose the page, click Default and save to switch to the default view.

"Save for everyone" fails with "managed in code". The page is configured in medusa-config.ts and you changed its default layout. Change the layout in the config instead, or remove the page from the config, arrange it in the admin and export it again.

A warning says the catalog is from another Medusa version. Upgrade the plugin to the version that matches your Medusa minor, see Compatibility.

Changelog

See CHANGELOG.md and the GitHub releases.

Contributing

Issues and pull requests are welcome. CONTRIBUTING.md covers the development setup, trying changes in a Medusa app, supporting a new Medusa version and the pull request checklist. Everyone taking part follows the code of conduct.

Security

Report vulnerabilities privately, as described in SECURITY.md.

License

MIT © Rok Mohar