16

I have webapp with firebase database. I would like hosting the app on firebase. My app has own server nodejs and using websockets. How can I host my app on Firebase? And how can I run my own server on Firebase?

jul56
  • 161
  • 1
  • 1
  • 3

6 Answers6

10

I think your question is quite simple. And the answer is also simple: no, you can't.

Firebase only serves static files. You need to try heroku, codeship, etc for that.

  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/13118831) – Billal Begueradj Jul 26 '16 at 00:51
  • 8
    @BillalBEGUERADJ this doesn't look like an answer, but it is. – Quill Jul 26 '16 at 12:33
  • I want to update my answer to: yes, it is now possible. Take a look here: https://youtu.be/c93iGKyvh3o – iforgotmypassword Jul 14 '17 at 19:16
9

I'm not sure what exactly you are looking for. I'll assume it's one of these two:

  1. you want to run the node.js scripts on Firebase's server

    There is no way to run your own code on Firebase's servers.

  2. you want to run the node.js scripts on your own server and have them interact with your Firebase data

    Firebase has a node.js package that allows you to talk to its BaaS service from your own node scripts. See the node.js section in Firebase's quickstart and the npm package for Firebase.

Community
  • 1
  • 1
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • But how can I run my nodejs server, when I have my server on firebase? – jul56 May 11 '15 at 16:21
  • 2
    I'm not following your question. Are you asking how you can run your node.js scripts on Firebase's server? In that case the answer is: you can't. Or are you asking how your node scripts (that run on your server) can talk to Firebase? In the latter case, the above links are really all there is to it. Are you getting an error message when you're running the scripts? – Frank van Puffelen May 11 '15 at 17:11
  • 1
    I think you want to use your own database server? – leandronn Sep 01 '16 at 18:54
3

You can use Google Cloud Functions to do most task processing in a serverless style: https://firebase.google.com/docs/hosting/functions

I'm using it to dynamically load javascript based on req.url.

Daniel Murawsky
  • 309
  • 1
  • 4
  • I have a doubt. I have two firebase projects: `react static website` and `api express with functions`. Can I access this functions with reactjs and react native using .. what: `firestore` or call to api from firebase url? – Francis Rodrigues Feb 18 '18 at 14:22
2

With Firebase functions, yes you can. You can watch this tutorial from Google, it's very clear and easy to catch up. Node.js apps on Firebase Hosting Crash Course - Firecasts

Linh Le Vu
  • 436
  • 4
  • 7
0

Firebase Hosting allows you to use Cloud Functions to perform server-side processing. This means that you can support dynamic generation of content for your Firebase Hosting site.

Documentation

Prata
  • 1,250
  • 2
  • 16
  • 31
0

Firebase Functions is the way to go.

Example:

  1. Setup /index.js in your project with expressjs listening on port what ever you want. F.e. 3000
const app = express()
const port = 3000
...
app.get('/', (req, res, next) => { 
    ... hier your code to handle request
})
...
app.listen(port, () => {
    console.log(`app listening at port = ${port}`)
    functions.logger.info("Application started", {structuredData: true});
})
  1. Export your function with reference to express-app:

exports.api = functions.https.onRequest(app)

drdrej
  • 904
  • 8
  • 14