Install Locator for Svelte

Install Locator on Svelte codebase.

Svelte support is experimental:
  • It does not show component's name and bounding box.
A

Browser extension (option A)

Easiest way to start with Locator is to install a Browser Extension
You can get extension for Chrome, Edge, Brave, Opera, Firefox
B

Library (option B)

If you would like to install Locator to your project, so all team members can use it. You can install it as a library.
npm install -D @locator/runtime
Add this to some global/root file, usually:index.js or App.svelte
import setupLocatorUI from "@locator/runtime";

if (process.env.NODE_ENV === "development") {
  setupLocatorUI({
    adapter: "svelte",
    projectPath: __PROJECT_PATH__,
  });
}
and add this to your vite.config.js
export default defineConfig({
  ...
  define: {
    __PROJECT_PATH__: `"${process.cwd()}/"`,
  },
  ...
});