Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding strapi to an express server

I want to build a self-hosted website with nodejs and the express framework because I'm already familar with that. However, using a CMS for this project is a requirement, so I'm looking for a suited and easy-to-use/-learn CMS and discovered strapi which I quite like.

Setting up an API with strapi is easy indeed but now I'm struggling with adding strapi to an express server. My goal is one express server with strapi, which also hosts the website. So, I can control the routing with express (which I'm used to) and can render the site on the server.

Can somebody explain me how to do that and maybe give a small example? The examples I found, are only about hosting the API externally and using a client-side web framework or a static site generator. Or is my vision not possible with strapi and I should use another CMS like KeystoneJS (which is already built on Express)?

Thanks in advance!

like image 447
Lorion Avatar asked Aug 23 '18 13:08

Lorion


People also ask

Is Strapi faster than WordPress?

The installation is made in less than two minutes and the admin panel doesn't reload upon saving. If you compare Strapi with WordPress, you'll see that WordPress is much slower than Strapi to deliver the same thing. The reason is in the technology WordPress and Strapi are built on.

Can Strapi be used as a backend?

Strapi is a headless CMS that allows you to easily build customizable backend services. You can integrate Strapi applications with any type of frontend and can deploy the application to the cloud. This tutorial guides you through the process of creating a simple React-native to-do app with Strapi as your backend.

How do I connect Strapi to next JS?

Installing Strapi Let's begin by creating a central folder that will hold the Strapi backend and Next. js frontend. To proceed, launch your terminal and enter the following command to create a project folder. The above command will create a new Strapi project and install the necessary dependencies.


1 Answers

Using Express with Strapi must be very complex and does not really make sense. Strapi is based on Koa, which has been designed by the team behind Express. If you are coming from Express, eyou will get confortable with Koa very quickly. Here is the documentation: https://koajs.com.

like image 106
Pierre Avatar answered Oct 14 '22 08:10

Pierre