Templates are pre-built designs that can be loaded into the editor so your users don't have to start creating everything from scratch in a blank editor.

There are two ways you to manage templates in Unlayer. You can either use Unlayer's template manager, or you can save the templates in your own database.

Unlayer Template Manager (Easy)

Unlayer provides a template manager where your designers can easily create and modify templates. Each template is given a unique ID which can be used during initialization or any time after that.

Here's an example on how you can do it during initialization by passing a templateId.

  projectId: 1,
  templateId: 123

Or, you can do it after initialization by calling the following function.

unlayer.loadTemplate(1); // 1 is the templateId

You can also use our REST API to fetch the templates from your server at any time.

On Your Own Servers (Advanced)

If you want to save the templates on your own servers, that can be easily done. Templates are exactly like regular designs created using our editor. So they can be saved and loaded using the same API.

Once you create the template in Unlayer's template manager, switch to the JSON tab to get its' JSON. You can save this JSON in your database.

After the editor is initialized, you have to pass the template JSON to the loadDesign method.

var template = {...}; // template JSON

Legacy Templates

If you want to switch to Unlayer and continue using your legacy rich text templates, you can do that using our classic mode. This is useful to make sure the existing templates and designs keep working for the users. Learn More