Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Supporting SSR scenarios

未关闭
#460 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp, node.js, react, typescript, vite
领域
backend, web-dev

调研方向

首先检查链接的原型,尤其是其中经过修改的 init.js、NodeSsrHost.cs 和 vite.config.ts,以及 issue #440 和 #330。明确预期的贡献是为已初始化的 CLR host 提供可复用的 SSR 支持、在构建时重写 import,还是两者兼具;done 应定义为已接受的设计和可正常工作的 SSR 覆盖范围。

由索引模型根据 Issue 内容生成。

描述

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.0 and there's an issue with that #440
  • You can't use the node-api-dotnet npm package vanilla within SSR context because the CLR host is already initialized #330

For the second issue, I've worked around it by patching the init.js manually and injecting a dotnetHost global, which works!

https://github.com/kamranayub/dotnet-ssr/blob/be9dc260c5cc23c31f037cc60e74872c7fd8d30a/web/patches/node-api-dotnet%2B0.9.15.patch

https://github.com/kamranayub/dotnet-ssr/blob/be9dc260c5cc23c31f037cc60e74872c7fd8d30a/src/server/NodeSsrHost.cs#L57-L71

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:

https://github.com/kamranayub/dotnet-ssr/blob/be9dc260c5cc23c31f037cc60e74872c7fd8d30a/web/vite.config.ts#L12-L65

主要语言
C#
星标
783
派生
80
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/node-api-dotnet 的其他 Issue

查看 microsoft/node-api-dotnet 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。