Enhancing Content Creation: Visual Editing with Sanity and Storyblok for Next.js
Tags: sanity, storyblok, nextjs, webdev
Published: 2023-12-21 11:45:00

As experts in headless CMS (hCMS) and performance at FocusReactive, we work with many products from this segment and closely monitor their development. But most often we choose those CMS that have integration with such a framework as [Next.js](https://nextjs.org/). While hCMS makes it possible to separate content and work with it independently, Next.js helps to achieve maximum performance using the built-in mechanisms and capabilities of the framework.

Sounds great, right?

If we talk specifically, then two players can be distinguished here: Sanity and Storyblok.

Another reason to go with either Sanity or Storyblok is that they offer visual editing functionality. Let’s dive into it and take a look at some of the main features they offer.

### What is Visual Editing?
Visual editing is a user-friendly method of creating and modifying digital content using graphical interfaces. It allows users, regardless of technical expertise, to directly interact with and manipulate content. Unlike traditional text-based editing, visual editing provides a real-time preview of how the content will appear on the page, increasing efficiency and collaboration among engineering and content teams.

### User Interface and Navigation

Both Storyblok and Sanity have quite similar UI regarding visual editing: you will find the URL of the page, a preview of the page, and a list of blocks used by the page. It is important because this is one step towards standardization, even though non-official.

![visual editing layout](https://cdn.sanity.io/images/vftxng62/production/6300c9df28121bb832407a94e50734c2f1cf0d46-1336x1366.png)

The visual editors of both platforms allow you to click on any component and open it in the content column on the right side of the page. Here is how it looks:

Storyblok
![storyblok - open content bar](https://cdn.sanity.io/images/vftxng62/production/35f7d73dcb02973b0764295f3e8a7eb241899bb0-800x500.gif)

Sanity
![sanity - open content bar](https://cdn.sanity.io/images/vftxng62/production/37956c55f91c8badf1c3402e1a9615b92a0b1765-600x424.gif)

This feature saves time and speeds up the editing experience, especially when dealing with complex components that consist of multiple nested components.

Both platforms will open top-level fields as well as nested child components. Depth doesn’t matter.

Moreover, in the case of Storyblok you will see the nesting hierarchy aka breadcrumbs. They are clickable, which gives you additional convenience when editing/navigating between nested components. Sanity doesn’t have that.

However, there are a couple of differences between the two platforms in the scope of this feature.

Let’s say you have a link and you want to go to another page by clicking it. It won’t work, because instead of going to another page, you will open the clicked component in the content column.

Sanity offers an "edit" toggler that turns it off and allows you to interact with the page.

![sanity - edit toggler](https://cdn.sanity.io/images/vftxng62/production/0a0d522353c681c9ba34dfb9909f058c45ff77c2-600x424.gif)

This feature is particularly useful when you want to preview and test the final result, including clicking links.

Unfortunately, Storyblok does not have this feature. But, at least, you can do something. Specifically, you can prevent the iframe events, like clicking on a link. To configure that you can use *preventClicks* property of *StoryblokBridge* instance (check out [official docs](https://www.storyblok.com/docs/Guides/storyblok-latest-js#usage-of-storyblokbridge)). But this is more of a technical change, that should be done in code, rather than in UI. So the content team can’t use it independently.

This can be frustrating in certain cases, especially when you develop a new functionality related to link behavior.

### Real-Time Preview and Instant Feedback

Both Storyblok and Sanity provide instant preview feedback when changing content. This means that any modifications made to components are reflected in real-time without any delay. This feature allows content creators to see exactly how their changes will affect the final appearance of the page, facilitating quick iterations and adjustments.

The importance of that is elegantly described in Sanity's blog as [What you see is what you edit](https://www.sanity.io/blog/introducing-presentation#1eb84f5d96d6). Both hCMS play well in this crucial field.

Let's see how it looks:

Storyblok
![storyblok - instant feedback](https://cdn.sanity.io/images/vftxng62/production/5721a02b1d0fe2c4ddc7ff977f1857993dee4d01-600x386.gif)

Sanity
![sanity - instant feedback](https://cdn.sanity.io/images/vftxng62/production/77b44c8ed0e853aa913016d595f6acd07870e0f4-600x424.gif)

They are both fast and convenient to use.

But what about applied changes persistence?

Sanity saves all changes with draft status, so if you reload the page, changes will be there. This could be cool when you working on the content and don't want to lose any changes, but might be annoying when doing some development/debugging work.

Storyblok, in turn, shows all the applied changes but doesn’t save them until you press "save" button.

Worth to mention tho, is that Sanity gives you the ability to edit any separate component, eg footer and header, and see instant feedback. Same behavior as all the other fields.

In case of Storyblok, the mechanism is a bit different. Let’s consider adding a reusable header component which you will share among the pages. You create a "story" (collection of fields) with header info and add a story field to the page. Then you should select one of the existing header stories as the value. And the last part is adding the header implementation in the code to make it work for all pages (eg use in layout, that is shared between pages).

This is not easy and not straightforward. This approach limits your preview and live editing experience for shared components, which is not what you want.

### Drag-and-drop and Copying Functionality

Drag-and-drop functionality is a must-have for any visual editor, and both Storyblok and Sanity offer this feature out of the box. It allows users to easily change the composition of a component and experiment with different layouts and designs. This intuitive and handy way of editing enhances the user experience and speeds up the content creation process.

Storyblok
![storyblok - drag-and-drop](https://cdn.sanity.io/images/vftxng62/production/032e8208c7b277e5ea3289ccb671b9b83fa61441-600x386.gif)

Sanity
![sanity - drag-and-drop](https://cdn.sanity.io/images/vftxng62/production/ec990ffe5e90e877c8c7665e72f07c891a8246ec-600x424.gif)

However, the efficiency of content creation is further elevated through the copying capabilities.

Storyblok has a convenient mechanism to copy and paste components through a clipboard. It allows copy-paste components across projects/pages/nested objects. Meaning that you can copy a component and paste it to another page and even to another project. On the other hand, Sanity opts for a more targeted approach, offering duplication functionality. This means you could create a component copy that will be added right next to the original component.

Let’s see the difference:

Storyblok
![storyblok - copying](https://cdn.sanity.io/images/vftxng62/production/9d815fd2eaa70f752af4235e48c9cfb6edacb09f-600x386.gif)

Sanity
![sanity - duplication](https://cdn.sanity.io/images/vftxng62/production/b427a42e72cc84829a9042029ba6cde84f05dd6a-600x424.gif)

In my opinion, Storyblok has a more convenient way of doing it. Because you can choose what components to copy (yes, you can select multiple components and copy them the same way you copy a single one) and where to paste it.

Sanity is limited to copying only within the array and one component at a time, which can cause some inconvenience in certain cases.

### Preview for Different Viewports

Another essential feature of visual editing tools is the ability to preview content for different viewports. For now, Sanity offers two options: desktop and mobile. While this provides some flexibility, it is limited compared to Storyblok. Storyblok allows users to preview content in mobile, tablet, and desktop viewports. Additionally, Storyblok enables users to preview content at any custom width, similar to widening the browser window. This level of customization ensures that content creators can accurately preview content across various devices and screen sizes.

Storyblok
![storyblok - responsive view](https://cdn.sanity.io/images/vftxng62/production/f7996b07875143cbf537d65c1082679b191f264e-600x386.gif)

Sanity
![sanity - responsive view](https://cdn.sanity.io/images/vftxng62/production/e5e7f104bb0ee8782c81d36ca7dbcfe657665e5e-600x424.gif)

### Collaboration and Communication

Collaboration is key in any content creation process, and Sanity takes it a step further. In Sanity, users can work alongside teammates without any worries about overwriting, locking each other out, or applying unexpected edits. Fields are independent, so multiple users can edit different parts of the same page without conflicts. Even more, Sanity shows who is editing a document in real-time and it works with live preview as well. (Wow!)

A common, but must-have feature, that is integrated in Sanity is document history. It keeps track of all the changes and you can always restore the particular version of any content.

![sanity - collab](https://cdn.sanity.io/images/vftxng62/production/1d82bf6c1004f0f9dced4ba3feb0452c0964dde6-600x795.gif)

Storyblok offers some of these features as well. It supports the same history feature, with the ability to restore specific page versions. However multiple users can’t edit the same page at the same time, because conflicts will occur. This is a significant limitation for the content team.

![storyblok - collab](https://cdn.sanity.io/images/vftxng62/production/90b2f9c2a30fb8d47882a37cc031066ef5c3cc99-600x424.gif)

One more great thing about both platforms is that you can leave comments on any component fields, tag team members, and ask questions or provide feedback directly within the editor. Tagged team members receive notifications, eliminating the need to switch between messaging platforms like Slack. This is nice because sometimes you don’t want to switch contexts and get distracted.

### Components composition

Both Storyblok and Sanity empower content teams to create multiple pages from existing components. This flexibility allows for efficient content creation and promotes consistency across the website or application.

However, it's important to note that the more pages you have, the more complexity lies with the content team. Changing components for one page could potentially affect other pages.

Sanity has addressed this issue by providing a clear overview of which pages use the content and how changes will cascade. This feature allows us to inspect the results on pages before making any changes public.

![sanity - used on pages](https://cdn.sanity.io/images/vftxng62/production/7fcf69dce67da919815fde639c0b33701a2e656e-1765x1250.png)

Unfortunately, Storyblok does not offer this feature, which can be a drawback when working with a large project. This is what I'm really missing in Storyblok.

### Implementation and set up

Implementation and Setup  The implementation of Sanity's visual editing involves using a new web standard called [Content source map](https://www.sanity.io/docs/content-source-maps) and the [@vercel/stega](https://www.npmjs.com/package/@vercel/stega) package for encoding and decoding page content. Other hCMS also adopt this approach for implementing visual editing.

Similarly, Storyblok has its own implementation, requiring the manual addition of special properties to each editable block by using the special helper function.

Both platforms use iframes in their implementation, making the setup steps quite similar. Here's a breakdown of the steps for each platform:

For Sanity:
1. Add [presentationTool](https://www.sanity.io/docs/presentation) to the project.
2. Add an API route to manage draft/published documents.
3. Connect your frontend application to the Sanity Studio.

For a more detailed guide and analysis, you can refer to our article: [A Deep Dive into Sanity's Visual Editing and Presentation Tool: The developer view](https://focusreactive.com/sanity-visual-editing-review/#setting-up-the-presentation-tool).

For Storyblok:
1. Add an API route to manage draft/published pages.
2. Add a preview URL to Storyblok.
3. Configure tokens.

For additional guidance, follow the [official docs](https://www.storyblok.com/tp/create-a-preview-environment-for-your-next-js-website).

In summary, the general process involves setting up a route to handle incoming requests and configuring the tools offered by either Sanity or Storyblok.

It's interesting to note that both products follow a similar approach. This not only validates the idea but also establishes a pattern, which is beneficial for developers and community users. Patterns are always a positive aspect!

### Conclusion

For headless CMS, visual editing tools play a crucial role in simplifying content creation, developing new features, and testing the result.

Both Storyblok and Sanity offer powerful and intuitive visual editors that empower content and engineering teams. While Storyblok was the pioneer in providing a visual editing experience out of the box, Sanity has entered the scene with its own set of impressive features.

Although both visual editing tools are very similar, you can’t decide which CMS to pick based on only this set of features. A lot of aspects should be taken into consideration before making a final call: tech stack, size and experience of the team, budget, level of communication between teams, need for customization, how good documentation is, potential risks, and more.

Check out related articles, that might help you make a final decision:
- [International and multilingual sites with StoryBlok and Next.js](https://focusreactive.com/storyblok-localization-part1/)
- [Project insides: How We Built a Complex Headless CMS Based on Custom Sanity Studio](https://focusreactive.com/sanity-cms-for-tipico-platform/)
- [Best Headless CMS for NextJS in 2023](https://focusreactive.com/best-headless-cms-for-nextjs/)
- [How to Choose a Storyblok Partner](https://focusreactive.com/how-to-choose-storyblok-partner/)

But, as always, the choice is dependent on your specific use case.  You should understand your system and business deeply, to make the right decision.

If you have any questions, [contact us](https://focusreactive.com/#mail-us), headless CMS experts, and we will help you to make this choice easier.