Serve HTML file with a serverless functon on base URL

I have a React app that I want to make SSR. By default, Netlify serves an HTML file on the base URL.
For example, I go to https://example.netlify.app => I get an index.html

Is it possible to run a netlify function when the base URL is hit so that I can use SSR?
For example, I go to https://example.netlify.app => function returns dynamic HTML.

Welcome to the forums @Eager-coder

That is not how Netlify is designed to run. You will lose all the benefits of publishing your site to a global CDN by doing what you are talking about doing. Plus, you need to ensure your render function returns within the 10 second execution limit.

However, should you wish to try it out, add a _redirect file to the root of your project with the line

/*    /.netlify/functions/<your-render-function>    200!

Not idea if this will work with a React App or not, but guess there is only one way to find out.

Interested to see if you get this working how well it performs.

1 Like

Hi @Eager-coder,

There’s an (not-so-exact) example here:

2 Likes