Server Side Rendering of templates Cloudflare Pages without ‘node:fs’

Hi guys,

I am trying to get a templating setup, using Mustache. Mustache however to render files on the server side requires the use of node:fs core module. Workers, however, is limited in what node modules it can support, according to - So Mustache templates cannot be read on the server side using node:fs

Here is my problem, I want to have several HTML templates & partials, in many separate files that I want to render on the server side (using workers). Then send it to the front end.

So, two questions.

a) Is there a workaround/hack allowing me to use Mustache for server-side rendering template files?

b) Can an alternative library/stack or technique help me achieve my goal?

You don’t have access to a filesystem. You can read the templates from your site’s output directory using fetch. See the documentation here.

1 Like

Thank you very much!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.