Menu

1 / 3

How I made SVG avatars byte-identical on server and client

DEV Community: react·Bhavik Bhensajaliya·9 days ago
#SJMMkFGd
#devtoreact#devto#dev#seed#every
Reading 0:00
15s threshold

Open the member list in almost any app. Most people never upload a photo, so you see a column of identical grey silhouettes.

The usual fixes each come with a catch:

Initials work until two people are both "JS". And white letters on bright tiles often fail contrast.

Random colors change on every render, unless you add a database column to store them.

Generated avatars are the right idea, but many use Math.random() or hard-coded SVG IDs. Then the server draws one face, the browser draws another, and your console fills with hydration warnings.

I wanted avatars I would never have to think about again. Same input, same bytes, on every server, in every browser and in every release. That became Opaline . This post covers what it gives you, how to use it, and the engineering that makes the promise hold.

Why you might want it

You want What Opaline does

Users you can tell apart Each seed gets its own face, colors and shape.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.