fastify / fastify-vite

Fastify plugin for Vite integration.
MIT License
849 stars 71 forks source link

[SPA] allowing passing additional context to the render function #140

Open felixmosh opened 6 months ago

felixmosh commented 6 months ago

Prerequisites

🚀 Feature Proposal

Currently SPA mode doesn't allows to pass additional context to the render function.

Motivation

I have a case that I wan't to render some stuff on the html not related to the React app.

For example, render app version inside a meta tag.

Example

reply.html({
      version: env.BUILD_VERSION
});
Shyam-Chen commented 6 months ago

Use https://vitejs.dev/config/#using-environment-variables-in-config?

felixmosh commented 6 months ago

Will it work inside the HTML? (In my case, I need it to be dynamic depending on the domain the app got served from)

galvez commented 6 months ago

As long as it's prefixed with VITE_, it will be picked up by Vite automatically.

But this feature request is very much worthwhile, I'll look into it and circle back.