Skip to content

Instantly share code, notes, and snippets.

@joeschoe
joeschoe / next-firebase-image-upoad.ts
Last active March 28, 2024 17:00
Upload images to firebase storage with next app router, server components, and server actions
// Use next app router, server components, and server actions to upload files to firebase storage
//
// you probably dont want to do this since just storing images in the next public folder is usually best
// but if for some reason you need to upload files to firebase storage from nextjs, here you go
// also worth noting that the firebase-admin storage sdk has almost no documentation
// and from what I can tell does almost nothing, but it's just a wrapper around the google cloud storage sdk
// so you can use that instead if you want better documentation and functionality
import { Readable } from "stream";
import { getDownloadURL } from "firebase-admin/storage";