A text download needs an appropriate filename and MIME type. Use the same content source for the on-screen preview and exported file.
Worked example
// components/PlainTextDownloadLink.tsx
export default function PlainTextDownloadLink({
filename = "notes.txt",
text = "Studio notes",
}: { filename?: string; text?: string } = {}) {
return (
<a
download={filename}
href={"data:text/plain;charset=utf-8," + encodeURIComponent(text)}
>
Download {filename}
</a>
);
}Implementation notes
Revoke object URLs that outlive their export interaction. Repeated downloads in a long-running application can otherwise retain unnecessary resources.
Try it yourself
Include non-ASCII text and inspect the downloaded document.
Open the React example →Editorial date December 13, 2025 · Published December 6, 2026