Backend and DB with NextJS - next.js

I started to create my project with NextJs, but I have some issues with the Backend of next js.
As Next is mostly the frontend part, how can I set up backend for next js?
I am looking for some tutorials to install BE, also I am interested to investigate some hostings. As I know, I can setup BE with Azure, some Express etc.
I will be happy if you share some knowledge about it.
Thanks!

Related

Best hosting option to start with for both dynamic website and WordPress

As a frontend engineer and where the freelance market seems to be, I'd like to dig into some WordPress stuff and build one for myself to at least know how to play around with it. And soon later I'll dig into backend and probably would deploy a dynamic website.
I'd like to find an option for a way that could host both, and also I can learn and develop more in such hosting method.
I tried heroku but its policy changed so the current way I forked on GitHub wouldn't be available soon. I cancelled bluehost subscription cause I believe it's not gonna be suitable for future deployment with dynamic website.
I've seen aws but its services are too many that I have no where to start with.
I'm so confused with all hosting options and iaas paas saas even tho I tired to read articles to understand them. Plus information online is like crazy a lot so that I have no idea which should I start with.
I am fine with paid service,
Could anyone share some experience with me?
If you are just getting started with web hosting you should use firebase hosting (You can't host Wordpress sites in firebase). It is completely free for hosting and also has a free database. You can deploy react.js apps or basic html,css,js websites in firebase. If you are using next.js you can check out Vercel. After exploring all of these you should try to get into the fun stuff such as Hostinger, WP Engine, DigitalOcean which support wordpress, static sites and dynamic sites.
I am not an experienced engineer like you are, but I have used these and trust me they are worth it. I hope this answer helps you

Firebase and Expo. Deploy Expo App. Hiding Keys

I see this question has already been asked but not all that recently so I am bringing it up again.
How do you hide your firebaseConfig file, or any secret key, in an expo application? (For production, not dev).
As far as I can tell, there is no way to properly hide the firebase config file with API keys etc in a react-native expo app.
Being that I have already built my entire app around interacting with firestore, I am a bit perplexed as to how to proceed forward.
If I eject, is there a way to properly hide my API key in a non-expo react-native-app? Or will I still face the same problem? Everything is working smoothly and I would prefer not to eject.
I have some experience using node.js/express.js as a backend (only ever in a development setting). Should I build myself a server and then serve the config info from there?
If I want to deploy a 'demo' app, is there a way to hide the keys while still using expo?
Any insight into this would be so helpful.
As far as I am aware there is no 'dotenv' package compatible with expo.
Also I have zero experience in deploying mobile apps, and very little in deploying web apps. I have not yet had to deal with securing keys in deployment.
Any help would be so appreciated.
It's not possible to effectively hide your Firebase config information. The best you can do is make it more difficult for someone to find them. Since all the JavaScript code is running on a computer or device that you don't control, you can't ensure that any of it is hidden from view.
In fact, you don't need to hide any of that. I suggest reading this: Is it safe to expose Firebase apiKey to the public?
If you're using Realtime Database, Firestore, or Cloud Storage, you should be using security rules to protect data so that only authorized users can access it.

Use different data for production and develop firebase sites

I have a CI/DC pipeline with google cloud build triggers that deploy my code to different sites depending on which branch I push to. The develop site is a live test - the final check before I merge to master, which triggers a deploy of master to the production site.
Currently, both sites use the same firebase Firestore db, and any document changed on the develop site will also be changed on the production site.
What I want to avoid is creating another firebase project to push the develop code to with a different database, because that means I need a separate set of credentials and would copy the same functions over to the new project every time I change them. That's not maintainable and is a lot of work.
What I would like is some way for the develop site to only have access to part of the firestore database, and the production site to have access to another part.
How do people do this? Is it even possible? Is there a better way? One alternative I can think of is using authentication and creating separate accounts for testing with different access permissions, but this seems a work-around and not the ideal solution.
What you're trying to do sounds like a lot more hassle than using multiple projects, which is the documented and strongly preferred solution. Putting everything in one project is a huge anti-pattern in Firebase and Google Cloud, and it will cause you more problems in the long run, in addition to increasing the risk of catastrophic failure if you manage to misconfigure something in that one project.
It's perfectly maintainable to have multiple projects like this, if you apply some scripting to automate the work. This is very common, and I strongly suggest thinking through how this would work for you.
You CI/CD pipeline could definitely check out your updates from source control and deploy them to whatever other project environments you have set up. It's very common to manage different credentials and configurations for use in CI/CD.

Do I still need a backend like RoR or Django if I use Firebase?

I am a Front-end developer with limited backend knowledge.
My question is do I need other backend frameworks like Django or Ruby on Rails if I use Firebase as a backend? In other words, can I solely depend on Firebase as a backend and build a single page web application or Mobile application without writing a single line of backend code?
Thanks for your time viewing the question.
I was also looking for a platform to minimize server code and I found that firebase can help a lot.
You will get plenty of docs on net. You can start at angular fire + firebase doc
https://www.firebase.com/docs/web/libraries/angular/quickstart.html
Following document was helpful for me to design my app, which requires some amount of off-line processing too.
https://firebase.googleblog.com/2013/03/where-does-firebase-fit-in-your-app.html

Juggernaut/Faye vs. Pusher for a Heroku hosted web service?

If I understand correctly, Juggernaut is built on top of socket.io, and Faye competes with Juggernaut layer and socket.io layer combined. Recently Ryan Bates came up with a Faye wrapper called PrivatePub which makes it very easy to run Faye.
But I already have a rails app that runs on Heroku, and all I want to do is build a simple chat feature on top of it.
While researching I found lots of people use Pusher. It seems like pusher is well supported on Heroku so I'm thinking about using Pusher.
Before I jump on, I just wanted to make sure I understand things correctly. Is Pusher like a Heroku for push requests? My option is to either host everything on Heroku (including Juggernaut or Faye module), or just host the static part of the site on Heroku and delegate push notification handling to pusher.
From what I know, this feels like a more efficient approach since:
1. If I use pusher, I don't have to jump through all the hoops in order to run juggernaut/faye modules on Heroku.
2. The realtime traffic will be delegated to Pusher, which means I won't waste my Heroku server's resource.
Now I'm just a beginner and may be wrong about lots of things, but please enlighten me. Are the two factors above correct? And is my understanding of Juggernaut/Faye/Pusher correct?
Thank you for asking about Faye/Socket.IO/Juggernaut/Pusher on Heroku. I will do my best to answer your questions. So you already have an App on Rails running on Heroku. And you need to learn more about which path to take for adding real-time updates via an always-on connection. All options you listed will work for this. Faye/Juggernaut will take a bit time to setup, yet provide same end-results. And Pusher is like it's own Heroku, separate from Heroku, and is readily simple to add to your app.
Your questions & answers:
Is Pusher like a Heroku for push requests?: Yes. Pusher is a separate service which has a separate pricing model, decoupled from your main Heroku bill. (though Heroku + Pusher are combined into a single monthly statement)
The real-time traffic will delegate to Pusher and not waste your Heroku Resources: Yes.
Are the two factors above correct?: Yes.
And is my understanding of Juggernaut/Faye/Pusher correct?: Yes.
If you want to learn more about Faye, Ryan Bates and Real-time here are some links:
Run Faye directly on Heroku: https://github.com/ntenisOT/Faye-Heroku-Cedar-RedisToGo
VIDEO: Faye Private Pub by Ryan Bates: http://railscasts.com/episodes/316-private-pub
GITHUB: https://github.com/ryanb/private_pub
You can run juggernaut node.js server on heroku.
You might need to share a redis database between your original heroku application, and the juggernaut application, if you are using the juggernaut gem.

Resources