Files
webstudio/packages/cli
Oleg Isonen b9801bb731 fix: Keep current page links active after anchor navigation (#6711)
A link to the current page loses its Current page styling after an
anchor jump or when opened with a hash. Keep the page link active, and
select only the matching section link when the URL has a fragment.

Ref #5377

## Changes
- Match path and query exactly.
- With no current fragment, match all links with that path and query.
- With a current fragment, match links without a fragment and links with
that exact fragment.
- Keep the existing `:local-link` polyfill to `[aria-current=page]`. An
explicit `aria-current` value can override that styling.
- Give static pages the browser URL after hydration and update link
state on fragment changes.

## Todo
- [x] Implement the mixed path, query, and fragment matching rule.
- [x] Cover plain links, router links, direct fragment loads, anchor
navigation, and static hydration.
- [x] Document the rule and its difference from standard `:local-link`
behavior, with the MDN reference.
- [x] Remove the redundant CSS selector rewrite, parser dependency,
generated schema snapshot, and unneeded history listener.
- [x] Run focused tests, typechecks, lint, formatting, and review the
final diff.
- [x] Confirm required CI checks pass on the latest cleanup commit.

## Verification
- SDK link URL tests: 18 passed.
- Plain React Link and hydration tests: 10 passed; hydration test passed
again after narrowing the subscription to fragment changes.
- Router Link tests: 23 passed.
- SDK, React Link, router, and CSS engine typechecks passed.
- Changed code passed oxlint, oxfmt, and `git diff --check`.
- Native fragment event behavior was checked in Chromium, Firefox, and
WebKit; hydration behavior was checked in Chromium.
- Required GitHub CI passed on
`9758b19a6d92c7ab8a2efc7efa553f725a68109f`; the empty Builder core shard
passed on retry.

## Behavior note
This mixed rule is Webstudio behavior, not the current CSS `:local-link`
draft, which ignores fragments on both URLs. Local Link styling follows
this mixed match. The mixed match also sets `aria-current="page"` by
default, including on section links. Authors can set another value
explicitly.
2026-11-18 00:35:46 +01:00
..
2023-09-01 13:50:24 +02:00

Webstudio CLI

The Webstudio CLI helps you to link, sync and build projects from Webstudio Cloud. This README will guide you through the process of setting up a Webstudio project on your local machine and continually sync it with the cloud.

Prerequisites: Installing Node.js

You need Node.js to use the Webstudio CLI. If Node.js is already installed in your system, you can skip ahead to the section on installing the Webstudio CLI.

To install Node.js using NVM, first install NVM by running:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Once NVM is installed, you can install Node.js version 22 by running:

nvm install 22

Verify your Node.js installation by checking its version:

node --version

Installing the Webstudio CLI

To get started with the Webstudio CLI:

  1. Download and install the CLI using the following command:

    npm install -g webstudio@latest
    
  2. Confirm the installation by checking the CLI version:

    webstudio --version
    
  3. To keep your CLI updated, use the same command used for installation whenever a new release is available.

Initiating a Webstudio Project

Now, you can run a Webstudio project on your local machine using this command:

webstudio

This will initiate the flow to connect your Webstudio Cloud project and build it in your local computer. The default flow will guide you through the steps. You can also perform all the operations individually using independent commands.

Commands

Here is the list of independent commands:

  • version
  • help
  • link
  • sync
  • build

The link command stores access to a Webstudio Cloud project. MCP clients use that connection to read and edit the latest Builder build directly; the project does not need to be published or synchronized first.

Shell-capable agents can call MCP tools directly as CLI subcommands immediately after linking. This does not require MCP client configuration or a client restart:

webstudio meta.index
webstudio components.search '{"brief":"button"}'
webstudio insert-fragment --input-file .temp/insert-fragment.json --dry-run

.temp/insert-fragment.json:

{
  "parentInstanceId": "<parent-id>",
  "fragment": "<section />"
}

The explicit equivalent is webstudio mcp single-op-call <tool> '<json>'. Use webstudio connect <client> only when you want persistent native MCP tools inside Claude Code, Codex, Cursor, or VS Code. A persistent client may need to reconnect after its configuration or cached tool catalog changes.

See the Webstudio MCP documentation for setup, discovery, editing, verification, and safety guidance.

You can link a project from Webstudio Cloud with the following command:

webstudio link

This command will prompt you to paste a link which you can create using the Share option in your project.

Make sure to provide Build access when generating the link in Webstudio Cloud.

sync

Once the project is linked, use the sync command to sync it with the cloud:

webstudio sync

Sync downloads the current saved Builder project and its asset files, then prepares the local content index. Publishing is not required.

Use the export with webstudio build or webstudio import --to "<target-share-link>". Sync is not required for MCP editing.

build

Now, you can build your project with the build command:

webstudio build

During this phase, the CLI establishes the necessary routes and pages, scaffolding the entire application using the default Remix template. Additionally, all assets, such as images and fonts are downloaded to the assets folder inside the public directory.

Once the project is scaffolded, you can run npm install and then npm run dev to run your app in development mode.

If you want to build a production version of the app, you can run npm run build.

Deployment

Vercel

Once you've built the project locally, you can use the Vercel CLI to deploy your project directly to Vercel:

vercel deploy

Follow the instructions here to install the vercel CLI. We plan to add more deployment targets in future.

Netlify

If you want to deploy to netlify, you can use Netlify CLI to deploy your project directly to Netlify:

netlify deploy

You can configure the project to support netlify serverless/edge-functions respectively, as deployment target at the time of initially setting up your project. Please check the initiating-a-webstudio-project section.

You can manually change it using the build command. For serverless functions:

webstudio build --template netlify

Important Notes

If you use vercel build before vercel deploy, make sure to clean your app folder in the project afterward.

Vercel injects a few files to support and deploy Remix using their CLI, but these files are not necessary for your project when you use it locally.