<?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[Stories by Kevin Nam on Medium]]></title>
        <description><![CDATA[Stories by Kevin Nam on Medium]]></description>
        <link>https://medium.com/@kevinnam_6540?source=rss-9e3a205d11b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WNV-02I50-FkC2sl.</url>
            <title>Stories by Kevin Nam on Medium</title>
            <link>https://medium.com/@kevinnam_6540?source=rss-9e3a205d11b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:28:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kevinnam_6540/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Get Started With Firebase In Less Than 5 Minutes]]></title>
            <link>https://medium.com/@kevinnam_6540/get-started-with-firebase-in-4-steps-f3b11f506935?source=rss-9e3a205d11b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3b11f506935</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Kevin Nam]]></dc:creator>
            <pubDate>Thu, 26 Jan 2017 18:18:49 GMT</pubDate>
            <atom:updated>2017-01-26T18:22:33.617Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we get started, I will be assuming you have already generated a clean Node.js &amp; Express project using express-generator. In the following picture, I’m using Atom as my editor tool and I generated a project named <em>test</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hB0UrlZ5e64dEJM9hTFYzQ.png" /></figure><h3><strong>Step 1</strong></h3><p>Open up views/index.hjs (or whatever engine you use). We need a way to link up our web page to our Firebase database. Add the following code with the appropriate configurations between your &lt;head&gt; tags. You can find this code with your configs through your Firebase console by finding “Add Firebase to your web app”.</p><pre>&lt;script src=&quot;https://www.gstatic.com/firebasejs/3.6.7/firebase.js&quot;&gt;&lt;/script&gt;<br>&lt;script&gt;<br>  // Initialize Firebase<br>  var config = {<br>    apiKey: &quot;&lt;API KEY&gt;&quot;,<br>    authDomain: &quot;&lt;AUTH DOMAIN&gt;,<br>    databaseURL: &quot;&lt;DATABASE URL&gt;&quot;,<br>    storageBucket: &quot;&lt;STORAGE BUCKET&gt;&quot;,<br>    messagingSenderId: &quot;&lt;ID&gt;&quot;<br>  };<br>  firebase.initializeApp(config);<br>&lt;/script&gt;</pre><h3><strong>Step 2</strong></h3><p>Great, now we are connected to Firebase. Now, let’s add two buttons to the page. <strong>One button for sending data to Firebase</strong> and <strong>one button for receiving data from Firebase </strong>like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oq2-sLLWHLOAxozdq0VUuA.png" /><figcaption>Please note that config is not properly setup for privacy purposes.</figcaption></figure><h3><strong>Step 3</strong></h3><p>So now with these two buttons, we want to be able to <strong>send (or push) data to Firebase by clicking the send button</strong> and <strong>we want to be able to receive data from Firebase by clicking the receive button</strong>. Simple enough. We’ll use <strong>jQuery</strong> for this. Add the following line to the bottom of your &lt;head&gt; tag to add the jQuery library:</p><blockquote>&lt;script src=”https://code.jquery.com/jquery-3.1.1.min.js&quot; integrity=”sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=” crossorigin=”anonymous”&gt;&lt;/script&gt;</blockquote><p>We will also add another line right under this as follows:</p><blockquote>&lt;script src=”/javascripts/firebasetest.js”&gt;&lt;/script&gt;</blockquote><h3>Step 4</h3><p>The last line we just added doesn’t make sense right now because we have yet to create the firebasetest.js file! So let’s make that right now. Create a <strong>firebasetest.js</strong> file in <strong>/public/javascripts/</strong>. Now, we will be using the jQuery library so that we can listen to button clicks and perform the correct actions. The code is as follows:</p><pre>// Initializes the firebase database<br>var db = firebase.database();</pre><pre>// Wait for all HTML to be loaded and starts jQuery here<br>$(document).ready(function(){</pre><pre>// When send button is clicked<br> $(“#send”).click(function() {</pre><pre>// Set data at reference point ‘testing/’ with text<br> firebase.database().ref(‘testing/’).set({<br> text: ‘it works!’<br> });<br> console.log(“Sending data…”);<br> });</pre><pre>// When receive button is clicked<br> $(“#receive”).click(function() {<br> console.log(“Receiving data…”);</pre><pre>// Get value once at reference point ‘testing/’ as a snapshot<br> firebase.database().ref(‘testing/’).once(‘value’).then(function(snapshot) {<br> console.log(snapshot.val());<br> });<br> });</pre><pre>});<br>|</pre><h3>Now let’s try it out!</h3><p>Start up the server with <em>nodemon</em> or good ole <em>node</em>. Go to <a href="http://localhost:3000/">http://localhost:3000</a> and open up the console. First click the Send button then the Receive button and you should get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkURdRXqpdU5aloKoAxBUg.png" /><figcaption>Working demo</figcaption></figure><p>If you go onto the Firebase console and look for Database, you’ll see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*Kh-EI5sjlGNcwCGzL1iJ1w.png" /><figcaption>Notice testing has a property “text” with the value “it works!”.</figcaption></figure><h3><strong>Congratulations! You have learnt how to send and receive data from Firebase in 4 steps (and hopefully less than 5 minutes).</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3b11f506935" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>