1# Runtime: `Runtime<R>` Removed
2
3In v3, `Runtime<R>` bundled a `Context<R>`, `RuntimeFlags`, and `FiberRefs`
4into a single value used to execute effects:
5
6```ts
7// v3
8interface Runtime<in R> {
9 readonly context: Context.Context<R>
10 readonly runtimeFlags: RuntimeFlags
11 readonly fiberRefs: FiberRefs
12}
13```
14
15In v4, this type no longer exists and you can use `Context<R>` instead.
16Run functions live directly on `Effect`, and the `Runtime` module is reduced to
17process lifecycle utilities.
18
19## `Runtime.runFork(runtime)` -> `Effect.runForkWith(services)`
20
21In v3, running an effect with dependencies usually meant pulling the current
22runtime from `Effect.runtime<R>()` and calling `Runtime.runFork(runtime)` inside
23the main effect.
24
25**v3**
26
27```ts
28import { Context, Effect, Runtime } from "effect"
29
30class Logger extends Context.Tag("Logger")<Logger, {
31 readonly log: (message: string) => void
32}>() {}
33
34const program = Effect.gen(function*() {
35 const logger = yield* Logger
36 logger.log("Hello from Logger")
37})
38
39const main = Effect.gen(function*() {
40 const runtime = yield* Effect.runtime<Logger>()
41 return Runtime.runFork(runtime)(program)
42}).pipe(
43 Effect.provideService(Logger, {
44 log: (message) => console.log(message)
45 })
46)
47
48const fiber = Effect.runFork(main)
49```
50
51In v4, use the same pattern with `Effect.context<R>()`, then run with
52`Effect.runForkWith(services)`:
53
54**v4**
55
56```ts
57import { Context, Effect } from "effect"
58
59class Logger extends Context.Service<Logger, {
60 readonly log: (message: string) => void
61}>()("Logger") {}
62
63const program = Effect.gen(function*() {
64 const logger = yield* Logger
65 logger.log("Hello from Logger")
66})
67
68const main = Effect.gen(function*() {
69 const services = yield* Effect.context<Logger>()
70 return Effect.runForkWith(services)(program)
71}).pipe(
72 Effect.provideContext(Context.make(Logger, {
73 log: (message) => console.log(message)
74 }))
75)
76
77const fiber = Effect.runFork(main)
78```
79
80If your effect has no service requirements, use `Effect.runFork(effect)`.
81
82## `Runtime` Module Contents
83
84The `Runtime` module now only contains:
85
86- `Teardown` — interface for handling process exit
87- `defaultTeardown` — default teardown implementation
88- `makeRunMain` — creates platform-specific main runners