Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


Libraries allow you to reuse code between scripts. Using libraries, you can:
  • reuse code between scripts, saving duplication.
  • collaborate on a larger project with other people by combining individual scripts as libraries.
  • build abstractions and encapsulate data.

using libraries

how to add a reference to library

  • open a script so that you see its script editor page.
  • tap the + button to the right of the library section.
  • tap on the library you want to use. You can rename it if you need to.
There is also a fast path to add libraries: simply search the name of the library from the editor, tap on the search for libraries button, and pick your library from the list!


After you add a library reference to your script, you can call any of the library's non-private actions by first tapping on the ? library button in the expression editor, then selecting the desired library, and then selecting the desired library action.

authoring libraries

Creating and publishing libraries is extremely easy. Once a script is marked as a library and published, it will be immediately available to all other users. When authoring libraries, try to follow the coding guidelines.

how to create a library

  • open a script in the editor and open the script properties (tap on script name in script editor).
  • check the this script is a library checkbox.
  • don't forget to tag your library with libraries and possibly a sub tag.
  • publish the script.


If defined in a library, the following members are inaccessable from outside the library, meaning they cannot be accessed by other scripts:
  • data (global variables).
  • art.
  • actions marked as private.
If you want to enable access to library data, you need to define accessor actions, e.g. get and set actions, that pass values into and out of the library script.


Any action containing the word example is considered documentation. The body of the action will be pretty-printed to the user when he is browsing the library. You can use markdown syntax in comments to format your documentation.
As with regular actions, the comment(s) at the beginning of a library action are treated as docs. Additionally, if you have a library action named foo then the markdown content of action docs foo (which should be private) will be treated as full-page docs for foo.


  • libraries cannot declare events.

advanced usage

sharing of data

When the same library script is referenced by two scripts, then by default the two library scripts will not share any state. There will be two separate stores for all library script data (global variables).


Consider a script S that references a library L1 which in turn references another library L2. You can rebind the reference of L1 to L2 in the library properties of L1 in script S.
  • You can rebind the entire referenced library L2 to any other library that S also references.
  • You can rebind any particular actions of L2 that L1 calls.

exposing types

Libraries can declare record types and use them internally. Additionally, object types can be used as input and output parameters of actions, and are therefore also visible externally. The users of the library have no direct access to fields of exposed objects, they can only read and write them through the methods of the library.

extension actions

A public action in a library, which takes an object type defined in the library as a first argument can be invoked as an instance member (learn more).