Link Resolving in Javascript

When working with field types such as Link or Rich Text, the prismic-javascript development kit will need to generate links to documents within your website.

Since routing is specific to your site, you will need to define your Link Resolver and provide it to some of the methods used on the fields.

Adding to an existing project

If you are incorporating into your exisiting javascript project, you will need to create a Link Resolver.

Here is an example that shows how to add a Link Resolver function.

var PrismicDOM = require('prismic-dom');

var html = PrismicDOM.RichText.asHtml(, function(doc) {
  // Pretty URLs for known types
  if (doc.type === 'blog') return "/post/" + doc.uid;
  if (doc.type === 'page') return "/" + doc.uid;
  // Fallback for other types, in case new custom types get created
  return "/doc/" +;