how to deploy next.js website on nginx for SSR - nginx

I built my reactjs website for a company but it needs SSR for shareing its pages on social emedias, therefore I want to migrate my website on next.js but am not sure how to do so, I tried googling it and only one good article that I found was this one https://dev.to/techfortified/how-to-host-nextjs-website-on-cpanel-2dij , but there is nothing said about the most important thing for me - can this type of deployment do SSR?

Related

Is there any way to add CMS to Nextjs website (such as Wordpress)?

I developed a website using Nextjs (Client side only, and used Nextjs for the SEO).
I wanted to ask if there is a way to convert this website somehow from Nextjs to Wordpress or anything else, or even somehow connect it to CMS application, so my client can modify images and content any time he want by his own.
Currently, the web application in Nextjs is pretty static, all the pages and conntent are hard coded wroten.
All my data are in JSON files and such are the images in the website.
Yes! This is a pretty hot topic right now, and there are many ways to accomplish it.
Here are the general guidelines:
Set up a "headless CMS" - this can be WordPress (set up in a special way so you are using just the backend) - or there are many other popular options, such as Contentful, Sanity, Prismic...
Your CMS needs to have an API for Next.js to use. If you go with WordPress, you can use the built-in REST API - or you can use the WP GraphQL plugin
This is such a popular topic, that if you search around, you'll find many helpful guides that go into more detail. You'll want to search "Next.JS with WordPress headless CMS"
Here's one example I found that uses GraphQL and looks fairly thorough.
Or, if you're not set on WordPress, check out Next.js-specific information for other popular headless CMS's - most of them will have specific documentation and guides for Next.JS - for example Sanity's Next.JS Guides.
WordPress is solid and flexible - but if you're not already a fairly strong WP developer, then I might recommend going with one of the more pre-packaged options (like Sanity, Prismic, Contentful, etc.) - many of them have a free tier.

Can a wordpress website be used as mobile app backend?

I have a project where I need to make a mobile app for a wordpress website. It will have some features that are not in the web app yet. I've made some research and there seems to be ways to make api requests to some endpoints that are made available by wordpress. I am a rookie when it comes to planning a backend structure, building it from scratch, and deploying it, but I have developed new features for an existing node.js backend for a mobile app before. Considering all of this, can I use the wordpress api for my mobile app without any security, performance, or compatibility issues or should I start building a backend for it?
Thanks in advance.
Yes, we can use WordPress website for mobile application backend.
For this we need to make an API request according to WordPress structure and database structure.
A new development in WordPress is the WP-API, which allows you to output your site content into a standardized JSON API. Since mobile apps normally use an API to get remote data, using the WP-API is a great way to get your WordPress data into a mobile app.
We can use inbuilt plugins for the same purpose like AppPreser- Mobile App Framework.

Mixing Wordpress eCommerce site with external login based Vue Frontend Best Practices

I am new to web development and and would like advice about what is the usual best practices to achieve what I am trying to do.
I am in charge of writing a frontend app using Vue. This frontend will require a login to access the app. The app will be hosted on Amazon.
However we are also wanting to build an eCommerce site in Wordpress or equivalent that sits on the root of the website, (eg www.mywebsite.com) with the app accessible through a "sign in" button. If the user presses the sign in button we want the location bar location to not change from the website they are on (www.mywebsite.com), even though the Wordpress site and Vue frontend may be stored on different locations/domains.
If the site is made in Wordpress, we can get another developer to do that webpage for us, while I work on the frontend. However we want the experience to be relatively seamless between connecting to the wordpress root site, clicking on the sign in button and being taken to the Vue frontend.
Is this possible? Do both sites have to be hosted on the same server for it to work (eg an Amazon EC2 server which hosts two webpages, the wordpress one and the vue one)?
Or can the wordpress put a link to the Vue frontend which doesn't change the web location to the user?
Or (worst case scenario) do we need to make both webpages in Vue as one Vue application, some pages requiring login to access and others not?
Thanks kindly for any assistance.
So in order to use Vue and WordPress together, you can either write 2 separate applications. One for the Frontend and one for the Backend, which is perfectly fine or you can simply write a WordPress Application with a Vue Theme.
This is how this could look like:
WordPress Backend
You can use a normal WordPress backend, where you can build the architecture you want to. In addition, you need to set up the REST-API Wordpress provides. So this also means, just use plugins which support it. Otherwise, you would need to write custom endpoints. For example, Woocommerce would be a good e-commerce plugin, since it supports the API.
Learn more about it here: https://v2.wp-api.org/
Of course, you can host your WordPress installation on Amazon. Here is a good guide for that: https://aws.amazon.com/de/getting-started/tutorials/launch-a-wordpress-website/
Notice: The REST-API is available in core since 4.7. If you are using an older version you would need to install a plugin.
WordPress Frontend
In order to create your Frontend, I'd recommend you to make a custom theme. Since you are just serving static files this can be done pretty easy. But still, you don't need to reinvent the wheel.
There's a really good starter theme out there: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
It comes with all the stuff you need to get started and since it is just a theme, you can simply set up a usual WordPress hosting without handling Domains of multiple applications.
In order to get the data from the Backend, you would simply make calls to the REST-API. Here's an example: https://github.com/EvanAgee/vuejs-wordpress-theme-starter/blob/master/src/api/index.js

Connecting Next.js to Wordpress

I have a fresh WordPress site set up on InMotion. I want to limit WordPress to the backend in terms of storing content and serving it via its API. I want to use Next.JS/React for the front end. My problem is that I am unsure how to connect the two.
Can anyone point me to a tutorial or provide advice on how I can install Next.JS in my site files? Where should Next.JS and its JS files reside? Once installed how can I have my Next.JS javascript files become the theme for my WordPress installation? I have searched the net but there is scant information on these questions. Thanks!
Basically you fetch data from the WordPress API (REST or GraphQL) to your Next.js or other React web application.
I recommend to not mix source code of both things - the React web app would be separate project, it is integrated with WordPress just through the API.
If you google "next.js wordpress" then you would find a few things:
https://github.com/zeit/next.js/search?q=wordpress&type=Issues
a few mentions of WordPress in this issue: https://github.com/zeit/next.js/issues/727
https://react-etc.net/entry/graphql-and-next-js-for-building-wordpress-sites-with-react-js
https://medium.com/#proposalpaul/next-js-3-0-headless-wordpress-in-production-a-deep-review-e9758d29c212

Deploying Polymer site on Firebase

I am a beginner in Polymer and Firebase.
I did every step that Polymer Setup and Firebase Setup instructions said but when I deploy the site on Firebase, I get completely different sites.
Also the navigation is distorted.
What do I need to do to fix this?
Below is the way the site appears on Firebase after being deployed.
Below is the way the site appears on localhost after being deployed.
Check out this: https://github.com/PolymerElements/polymer-starter-kit/issues/550 and related issues.
Be sure then to use the latest version of everything!

Resources