Sketch.app

You can integrate Sketch into your app or workflow using the sketch:// URL scheme. You can even open documents in Sketch already focused on specific layers or with a specified zoom level.

Note: If a document is already open the canvas view does not change.

Table of Contents

Center layer and specify zoom level

The URL scheme accepts two parameters. If the path to the file is provided without any parameters the file will be opened in the same way it was last saved.

sketch://path/to/file.sketch?centerOnLayer=LAYER_ID&zoom=ZOOM_LEVEL

centerOnLayer string

To obtain the layer id use either the JavaScript API or read the document’s JSON data directly.

Example

To get the id of the current selection, select a layer within the current document in Sketch and run the following script from the Run Script… panel in the Plugins menu.

const document = require('sketch/dom').getSelectedDocument()

document.selectedLayers.forEach((layer) => console.log(layer.id))

zoom number

Actual Size has a zoom level of 1. To zoom out specify values between 0...1 while using values greater than 1 to zoom in, e.g. 2 for 200%.

Run a plugin command

Availability: Sketch 55+

Run a plugin command and pass query parameters to the a JavaScript handler.

sketch://plugin/my.plugin.identifier/my.command.identifier

Example

The command must implement the HandleURL action and have it defined in the plugin manifest in order to be run.

command.js
const sketch = require('sketch')

// If you're using skpm: export function handleURL(context)
function handleURL(context) {
  let query = context.actionContext.query
  sketch.UI.message(query.msg || '👋')
}
manifest.json
{
  "identifier": "com.example.sketch.messenger",
  "commands": [
    {
      "name": "Message",
      "identifier": "message.show",
      "script": "command.js",
      "handlers": {
        "actions": {
          "HandleURL": "handleURL"
        }
      }
    }
  ]
}
URL

Open the following link to display a Hello World message within an open document. Provide any URL encoded string with the msg query parameter.

sketch://plugin/com.example.sketch.messenger/message.show?msg=Hello%20World

Add a shared Library

Add a Library hosted on any server and shared using RSS by specifying the URL to the appcast.

sketch://add-library?url=APPCAST_RSS_URL

url string

URL-encoded string specifying the address of the appcast RSS file.

Example

URL to install the Apple iOS Sketch Library from Apple Design Resources.

sketch://add-library?url=https%3A%2F%2Fdeveloper.apple.com%2Fdesign%2Fdownloads%2Fsketch.rss

To find out more about sharing your own libraries, see:

Not a developer? Submit an idea

If you don’t have the programming experience to create your own Sketch plugin or integration, you can submit an idea to let our team and the community know what kind of functionality you’re looking for.

Take a look at the list of plugins the community has already built.