2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Next.jsをFirebaseにデプロイすると<Image>が使えない

Last updated at Posted at 2024-08-24

はじめに

Next.jsのアプリケーションのデプロイで動作が予想通りに行かなかったのでまとめます

問題

以下のようなコードを書いてでデプロイをしたところ画像が表示されませんでした

 <article className="flex items-center w-[300px] cursor-pointer group">
            <div className="relative">
              <div className="w-24 h-24 rounded-full overflow-hidden">
                <Image
                  src="/sample-article.jpg"
                  alt="sample article"
                  width={100}
                  height={100}
                  className="object-cover object-center w-full h-full group-hover:scale-110 transition-transform duration-300"
                />
              </div>

image.png

解決方法

Firebaseとの相性が悪く画像最適化するImageタグが使えないようです。

HTMLの<img>タグに変えることで表示するようにしました

ちなみにsvgはうまく読み込める。pngwebpjpgなどはできなさそうでした

おわりに

FirebaseでNext.jsをやるなら新しいFirebase Appを使うほうが良さそうです

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?