Do I need to build a Portable Text editor from scratch?
Good news - you don't have to build everything from scratch! While the Portable Text specification itself is published as an open standard, there are also open-source editor components you can use.
The @portabletext/editor package is available on npm and provides the core editing functionality for creating Portable Text. This is the modern, actively maintained editor package that powers the rich text editing experience in Sanity Studio.
Important context:
The editor is primarily designed for use within the Sanity ecosystem, so using it standalone requires some integration work:
- You'll need to handle your own schema definitions and validation
- Storage and persistence logic is up to you
- It's built for React environments
- Documentation focuses mainly on Studio integration and customization
- You'll be working with lower-level primitives rather than a plug-and-play solution
Alternative approaches to consider:
Embed Sanity Studio - Since Studio is just a React app distributed as an npm package, you can embed it directly in your application if you want the full editing experience with everything wired up
Use Sanity as your editor - Many teams use Sanity Studio as their editing interface (even if their content is consumed elsewhere) because it handles all the complexity of schema validation, real-time collaboration, and content management
Adapter approach - Some developers have built adapters for other rich text editors (like TipTap) to output Portable Text format, though these are typically community efforts
The broader ecosystem:
For rendering Portable Text (not editing), there are well-maintained libraries like @portabletext/react and similar packages for other frameworks. Tools like @sanity/block-tools help convert HTML and other formats into Portable Text.
So while you can build an editor that outputs Portable Text using the open-source packages, it's definitely more straightforward within the Sanity ecosystem where all the pieces integrate seamlessly. If you're building a custom CMS or editing interface, @portabletext/editor is your starting point, but expect to do significant integration work.
Show original thread1 reply
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.