-
Notifications
You must be signed in to change notification settings - Fork 75
Description
One of my motivations to use this is for using my .NET server as a runtime for my React frontend. In order to do that, I need to execute SSR code through Node.js in .NET and I think the two options right now are edge-js and node-api-dotnet.
I've completed a prototype of supporting React Router SSR with node-api-dotnet here:
https://github.com/kamranayub/dotnet-ssr
However, I did run into a few issues:
- Debugging doesn't work, since it's targeting
net8.0and there's an issue with that jsdom blows up on net 9 but works on net 8 #440 - You can't use the
node-api-dotnetnpm package vanilla within SSR context because the CLR host is already initialized Importingnode-api-dotnetinto node into a dotnet app #330
For the second issue, I've worked around it by patching the init.js manually and injecting a dotnetHost global, which works!
I think this could be contributed back to the library, but not sure where/how to do that. I'm up for it if that would be accepted, I just need some guidance.
I haven't yet prototyped this with edge-js, I only know it also does in-proc communication -- what I don't know is if I can set it up like this so the SSR code can invoke .NET APIs, plus I love that this generates the typedefs which make this work great under Vite dev mode 🚀
To get that working, you need to rewrite the import paths at build time: