react-server.config.ts / runtime / add local module #238
-
How can I add local code in // react-server.config.ts
import { eventStore } from "./src/server/eventStore";
export default {
runtime: (runtime: Record<string, unknown>) => ({
...runtime,
eventStore: eventStore(), // put your instance in the runtime store
}),
}; Error with
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @aheissenberger! You should be able to use TypeScript like above to define This feature was not fully finished and is only mentioned once in the docs, in a somewhat hidden manner. The necessary functions were not available from a public export, and they were also not documented. The runtime context is an internal async local storage that can be extended through configuration, but I have not seen any use case for it so far. You should define the Could you please share more about your use case and why you were trying to implement it using the runtime context? This runtime context is used by the framework as a global store, allowing access to these global variables everywhere, including configuration, worker threads, server context, live IO, logger, manifests, import maps, and module loading helpers. In other words, these are encapsulated global variables, not polluting |
Beta Was this translation helpful? Give feedback.
Hi @aheissenberger!
You should be able to use TypeScript like above to define
runtime
when #239 is published as soon as checks are finished.This feature was not fully finished and is only mentioned once in the docs, in a somewhat hidden manner. The necessary functions were not available from a public export, and they were also not documented. The runtime context is an internal async local storage that can be extended through configuration, but I have not seen any use case for it so far.
You should define the
runtime
in thereact-server.runtime.configt.ts
file to use the custom remote context entries in production too. Only this runtime configuration file will be part of a production buil…