Let's take for example the server.js Hello World
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World");
}).listen(80);
How can I use it in Firebase ?
Sorry for the duplicate but the answers were 3yo
(Update: Now the answer is: Yes, you can - see updates below)
No, you can't. Firebase hosting is only for static content.
See: https://firebase.google.com/docs/hosting/
Firebase Hosting provides fast and secure static hosting for your web app.
You need either a service like Heroku that can run your Node app, or you need your own server where you will install Node and run your app.
Now you can host your Node apps on Firebase directly - thanks to Ayyappa for pointing it out in the comments.
See this excellent video tutorial:
and the documentation:
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
Note that this is still in Beta:
This is a Beta release of Google Cloud Functions. This API might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With