Dynamic serverless sites on Github Pages (for those who don’t know, serverless use third-party API servers)



    Surely many have heard about github pages and that you can host static sites there (generated and uploaded there). But I would like it to be dynamic in this case, that is, it would be possible to fill in the code once and fill it up like on a real TsMSke, moreover, there was authorization, dynamically loaded data and all that. Right? So I wanted this. Come under the cut, I will show what I did.

    To begin with, as promised, I’ll show you what happened, and then I’ll tell you the details (keep tabs on changing tabs and page addresses).


    So what is going on here? I recently wrote about writing headless-cms, code-named Prisma CMS .

    But as I wrote, the initial idea was that although the server and the front are friendly with each other, they still need to be able to live their own lives and are independent units. And if the server follows the current trend of headless-cms / api-first-cms, then the front follows another concept - serverless. That is, if we launch a separate front, we simply specify the endpoint of the API server (it is not necessary on the same domain), and the data will be pulled by the API (and authorization will work).

    But that is not all. On the offsite, I wrote an articleabout the fact that on prisma-cms.com everyone can create a website for themselves on a subdomain that will use a single database, but you can individually design your own website for yourself. So, if you copy the prisma-cms.github.io repository to yourself , you will get your own site, as shown in the video.

    But you can even raise your own server and site. Here are the source code for the site: https://github.com/prisma-cms/prisma-cms.com . Deploy on your server and run. If everything works, specify your endpoint API here and collect with the PUBLIC_URL =. / Yarn build command.
    Everything, the site is ready. Now, following the official instructions, fill in the contents of the build folderon github and you have your own website with your API (you can use one API to work with a bunch of separate static sites, each of which can be with its own design).

    And it was not for nothing that I used a picture labeled Social coding. As you can see in the video, all the templates created on any of the sites using a single database can be used in the design of other sites. That is, in the future, if there is sufficient interest, it will be possible to create a single marketplace of templates and parts of templates for quickly creating sites from ready-made components.

    Have a nice coding!

    Website itself: prisma-cms.github.io

    Also popular now: