<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Wisekingdom.co - Medium]]></title>
        <description><![CDATA[Empower People via Education - Medium]]></description>
        <link>https://medium.com/wisekingdom-co?source=rss----20b4073fc769---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Wisekingdom.co - Medium</title>
            <link>https://medium.com/wisekingdom-co?source=rss----20b4073fc769---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:57:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/wisekingdom-co" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploy Next.js SSR บน Firebase Hosting และ Firebase Functions]]></title>
            <link>https://medium.com/wisekingdom-co/deploy-next-js-ssr-%E0%B8%9A%E0%B8%99-firebase-hosting-%E0%B9%81%E0%B8%A5%E0%B8%B0-firebase-functions-35f6ad23ada0?source=rss----20b4073fc769---4</link>
            <guid isPermaLink="false">https://medium.com/p/35f6ad23ada0</guid>
            <category><![CDATA[firebase-cloud-functions]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[firebasehosting]]></category>
            <dc:creator><![CDATA[Isman Usoh]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 12:41:47 GMT</pubDate>
            <atom:updated>2019-08-04T15:45:03.768Z</atom:updated>
            <content:encoded><![CDATA[<p>เนื่องจากว่าได้มีโอกาศเขียน <a href="https://nextjs.org/">Next.js</a> เลยหาข้อมูลว่าจะ deploy ที่ใหนกัน ที่ง่ายๆ เร็วๆ Learning curve น้อยๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSiqGiv1zxyCLXeaH5tiIw.jpeg" /></figure><p>สุดท้ายตกลงปลงใจว่าจะลอง deploy บน firebase hosting ด้วยเหตุผลที่ว่า ตั้งค่าง่าย deploy เร็ว และ frontend คุ้นเคยกับ product ของ firebase อยู่แล้ว</p><p><strong>แต่!!</strong> <a href="https://firebase.google.com/docs/hosting">Firebase hosting</a> ไม่รองรับ Service Side Render หรือ SSR</p><p><strong>แต่!! </strong>สามารถใช้ <a href="https://firebase.google.com/docs/functions">Firebase cloud function </a>ช่วยทำ SSR ได้</p><h3>เริ่มต้นกันเลย</h3><p>สร้างโปรเจ็ค NextJS</p><pre>mkdir ./firebase-nextjs &amp;&amp; cd ./firebase-nextjs</pre><pre>// สร้าง package ใหม่<br>yarn init -y</pre><pre>// ติดตั้ง dependencies ที่จำเป็น<br>yarn add next react react-dom isomorphic-unfetch</pre><p>สร้าง NextJS app ง่ายๆ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e595745964c3f6d68899ef234a45fb7f/href">https://medium.com/media/e595745964c3f6d68899ef234a45fb7f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f7a03a1d244a09f52de4a90fdff93b6/href">https://medium.com/media/2f7a03a1d244a09f52de4a90fdff93b6/href</a></iframe><p>ลองรันดูด้วย</p><pre>yarn dev</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtAab8hOytJaBevL8z7lcA.png" /></figure><p>รันได้แล้ว ขึ้นตอนถัดไป เรามาติดตั้ง firebase cloud functions</p><pre>firebase init functions</pre><pre>// ติดตั้ง dependencies ของ NextJS ลงใน cloud function package ด้วย<br>yarn --cwd ./functions add next react react-dom isomorphic-unfetch</pre><p>สร้าง cloud functions สำหรับเรนเดอร์ NextJS</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0c84f670df6314fd415c09411af62d7/href">https://medium.com/media/e0c84f670df6314fd415c09411af62d7/href</a></iframe><p>ตั้งค่าโฟรเดอร์ สำหรับเก็บไฟล์ Build ของ NextJS</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/059727c979dffa41818e06fd0dac1462/href">https://medium.com/media/059727c979dffa41818e06fd0dac1462/href</a></iframe><p>เสร็จแล้ว ฺBuild ใหม่อีกครั้ง</p><pre>yarn next build</pre><p>ทดสอบรัน cloud function</p><pre>firebase serve --only functions</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKRvBDmKuTvgTfY8eUzlLw.png" /></figure><p>สามารถรันแต่ ไม่สามารถโหลด static file แก้ไขการเพิ่ม firebase hosting กำหนด rewrites function โดนเป็นชื่อฟังชันที่รัน NextJS SSR</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99e388c1d50ce108b6cd3ce09634fd5e/href">https://medium.com/media/99e388c1d50ce108b6cd3ce09634fd5e/href</a></iframe><p>รันใหม่อีกครั้ง</p><pre>firebase serve --only hosting,functions <br>// เปิด <strong>http://localhost:5000</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2nJzfg1bUtUDhY2sgBKXg.png" /></figure><p>จะเห็นว่ามีการเรียก static file จาก cloud function ไม่ได้เรียกจาก firebase hosting แก้ไขด้วยการย้ายไฟล์จาก ./functions/next/static ไปที่ ./public/_next/static</p><pre>// สร้างไฟลเดอร์ public สำหรับ firebase hosting<br>mkdir -p ./public/_next</pre><pre>// คัดลอกไฟล<br>mv -v ./functions/next/static/ ./public/_next/static</pre><p>สุดท้าย deploy ทุกอย่างขึ้น firebase</p><pre>firebase deploy --only hosting,functions</pre><p>Demo: <a href="https://functions-nextjs.firebaseapp.com/">https://functions-nextjs.firebaseapp.com/</a></p><p><a href="https://github.com/isman-usoh/firebase-nextjs">isman-usoh/firebase-nextjs</a></p><blockquote>Ref: <a href="https://firebase.google.com/docs/hosting/functions">https://firebase.google.com/docs/hosting/functions</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35f6ad23ada0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wisekingdom-co/deploy-next-js-ssr-%E0%B8%9A%E0%B8%99-firebase-hosting-%E0%B9%81%E0%B8%A5%E0%B8%B0-firebase-functions-35f6ad23ada0">Deploy Next.js SSR บน Firebase Hosting และ Firebase Functions</a> was originally published in <a href="https://medium.com/wisekingdom-co">Wisekingdom.co</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>