Get entry preview URL from SDK

Hi, I’m working on a sidebar app using the contentful app framework. I’m looking for a way to get an Entry’s associated preview url from the sdk but the docs don’t mention anything about this. I would assume that this should be possible, am I overlooking something?

1 Like

Hi @developer2 ,

Usually a Preview URL is constructed as:

  • ‘your preview host’ (using Preview API), something like
  • ‘content tree’ - optional, this is usually decide by your app, can be as simple as /ctf or as complex as a built category tree /media/phone
  • ‘entry slug’ - that’s the slug that is in every entry (it’s usually auto-generated, but could be personalised). Something like /my_new_blog_post

For most use cases, it’s usually just the preview host and the entry slug.

I’d like this functionality as well. A use case is having a single point of truth for route generation of entries. If I the Content Preview URL of an entry was returned in the GQL payload, it would make it much simpler to build links to entries. Instead, I need to both populate Contentful Preview URls as well as have seperate logic in my code that turns an entry into a URL.