Migrating client-side state

I’ll need to do this because I’ve made a certain number of client side apps that I’d like to host elsewhere.

This post is your reminder/notice: if you want to do this, it has to be before hosting ends. In 2026, a redirect will not let you transfer the data programmatically.

A few years ago, this would have been much simpler in theory. You could make an iframe to the new site and postMessage all sorts of stuff in. But now there’s “state partitioning” (State Partitioning - Privacy on the web | MDN), and an iframe won’t have access to the embedded site’s actual storage.

Some guy on the internet explains how Wordle migrated its localStorage data to the nytimes domain by loading everything into a JavaScript object, serializing it in JSON, and redirecting to the new site with a great big URL parameter.

That works well if you can suitably put everything in a URL. There’s no frame action, so both pages have access to their own normal storage. I’m not sure if there’s a reliable way to do access control on the destination to make sure other unrelated sites don’t try to link people to incorrect data-import.html?data=... sort of links. Maybe checking the referrer would work. Does the web even do referrers these days :roll_eyes:

4 Likes

ugh I hadn’t even thought about this for all of my heardles… thanks for the info

maybe with access to a server you can send that data to a server, the server stores that data and returns a short code, then redirect to the new url with that code, fetch the server for the data from the code, and load it.