SVG whiteboard implementation with TypeScript and SVG.js
The task
In a recent project cliizii.com, a client wanted to have a drawing board in a browser where multiple users could interact. They already had a working whiteboard that we would have to redesign and improve according to their needs.
The problem
When we looked at the whiteboard’s code, we immediately realized that it wouldn’t work in the long term. The library version being used was outdated, and a lot of the source code could be improved, since new patterns had appeared in that area. The update to the newest version wasn’t possible without digging into the version history.
The solution
After talking with the client, we got approval to start over from scratch. But that raised a few questions – Canvas or SVG? Are there ready-to-go implementations? If not, what libraries could we use for our own implementation?
Canvas or SVG?
The first question we addressed was whether to use Canvas or SVG. We dug into Google to search for ways that Canvas and SVG were being used and the differences between them. Then we decided which was the best for our needs. We found this article that summarizes our research well. Here are the relevant things for our drawing board that we discovered:
The problem
When we looked at the whiteboard’s code, we immediately realized that it wouldn’t work in the long term. The library version being used was outdated, and a lot of the source code could be improved, since new patterns had appeared in that area. The update to the newest version wasn’t possible without digging into the version history.
The solution
After talking with the client, we got approval to start over from scratch. But that raised a few questions – Canvas or SVG? Are there ready-to-go implementations? If not, what libraries could we use for our own implementation?
Canvas or SVG?
The first question we addressed was whether to use Canvas or SVG. We dug into Google to search for ways that Canvas and SVG were being used and the differences between them. Then we decided which was the best for our needs. We found this article that summarizes our research well. Here are the relevant things for our drawing board that we discovered:
- Canvas is resolution-dependent, so drawings don’t scale cleanly. Supporting mobile screens would have been harder to implement.
- SVG elements allow us to interact with them (different DOM events, CSS styles, etc.).
- Because SVG is an XML format, it makes saving to a database pretty easy. This also helps us create PDFs from the drawing board.
Result
Users could try the whiteboard with a free trial at cliizii.com. That site is no longer online. Thank you! Update (October 2026): This 2017 project used SVG.js 2 and its draw, select, resize and drag plugins. SVG.js 3, released in December 2018, moved to the npm package@svgdotjs/svg.js, split the library into ES modules and changed parts of the API (for example, SVG.Doc became SVG.Svg). The 3.x line and its plugins are still maintained under the @svgdotjs scope (see the SVG.js installation guide). Table of content
Need a reliable tech partner?
20+
Years in business
80+
Senior engineers
200+
Projects delivered