You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read the document and the current way Bun writes files is:
constdata=`It was the best of times, it was the worst of times.`;awaitBun.write("output.txt",data);
If new content needs to be added and written, then the node: fs module needs to be used,
import{appendFile}from"node:fs/promises";awaitappendFile("message.txt","data to append");
Is it being considered to add an optional parameter to Bun.write() or introduce a new method like Bun.appendWrite() to indicate appending new content? I feel this aligns well with Bun's inherent characteristics and makes it more concise
What is the feature you are proposing to solve the problem?
Add an optional parameter to Bun.write() or introduce a similar method Bun.appendWrite()
What alternatives have you considered?
Using the solution introduced in the official documentation
Reacted by David Ben Kalifa, Marian Šámal, Kilian Brachtendorf, Luis Marin Aguilera, Dhaval Srivastava, Michal Kovac, q3boy, Alexandre Seo, suin, Muhammad Saqib and 13 more
Activity
mangs commentedon Apr 24, 2024
FileSinkdoes what you're looking for: https://bun.sh/docs/api/file-io#incremental-writing-with-filesink[-]Append writing new content when writing files[/-][+]Support appending files with `Bun.write` [/+][-]Support appending files with `Bun.write` [/-][+]Support appending files with `Bun.write`[/+]gutenye commentedon Apr 26, 2024
FileSink does not, it clears file content first before writing.
mangs commentedon Apr 26, 2024
You're right, I realized that after I wrote this and forgot to come back and change this. Thank you for making this clear.
VesperQuartz commentedon Jun 16, 2025
Yes we need this!
KilianB commentedon Aug 16, 2025
Appending to a file is such a common occurrence that at the end of the day I always have to fall back to the fs module.
Atulin commentedon Sep 16, 2025
Crazy that appending to a file is not a thing yet
K-Mistele commentedon Nov 17, 2025
+1, would love to see appending with filesink!
2 remaining items
Atulin commentedon Feb 22, 2026
The state of the issue, is that we'll be celebrating its 2nd anniversary in two months! 🎉
nyxar77 commentedon Feb 23, 2026
i don't think i can live that long
BunFile.appendorBun.append#16768 as a duplicate of this issueMrDanielHarka commentedon Aug 21, 2026
I need this!
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer
Add an append option to Bun.write, BunFile.write and BunFile.writer