Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
76d734d
docs: document Signal class for v2
bowheart Jul 23, 2025
3b226d1
docs: document `injectSignal` injector for v2
bowheart Jul 23, 2025
25f5442
docs: document `ZeduxNode` class for v2
bowheart Jul 23, 2025
b85ec47
docs: document `AtomInstance` class for v2
bowheart Jul 23, 2025
dda386e
docs: document `Ecosystem` class for v2
bowheart Jul 24, 2025
7399aa8
docs: document `AtomTemplate` class for v2
bowheart Jul 24, 2025
8feebc5
docs: document glossary for v2
bowheart Jul 24, 2025
08ab6e6
docs: document `atom` factory for v2
bowheart Jul 24, 2025
15ab275
docs: document `AtomApi` class for v2
bowheart Jul 24, 2025
cd3e5c1
docs: document `api` factory for v2
bowheart Jul 24, 2025
98223ed
docs: document `SelectorInstance` class for v2
bowheart Jul 24, 2025
142c2f6
docs: document `AtomProvider` component for v2
bowheart Jul 24, 2025
66a18e6
docs: document `EcosystemProvider` component for v2
bowheart Jul 24, 2025
a653a5e
docs: document `ion` factory for v2
bowheart Jul 24, 2025
a4bc835
docs: document `MappedSignal` class for v2
bowheart Jul 24, 2025
040c9b2
docs: document `useEcosystem` hook for v2
bowheart Jul 24, 2025
81d257f
docs: document `createEcosystem` factory for v2
bowheart Jul 24, 2025
ecf9bd9
docs: document `injectEcosystem` injector for v2
bowheart Jul 24, 2025
2a4365c
docs: document `useAtomContext` hook for v2
bowheart Jul 24, 2025
4f03145
docs: document `useAtomInstance` hook for v2
bowheart Jul 24, 2025
09f5137
docs: document `useAtomSelector` hook for v2
bowheart Jul 25, 2025
f4797fc
docs: document `SelectorTemplate` type for v2
bowheart Jul 25, 2025
6a96082
docs: document `useAtomState` hook for v2
bowheart Jul 25, 2025
12d4322
docs: document `useAtomValue` hook for v2
bowheart Jul 25, 2025
f4b616f
docs: document `injectAtomInstance` for v2
bowheart Jul 25, 2025
df53ac7
docs: document `injectAtomState` injector for v2
bowheart Jul 25, 2025
95aaf09
docs: document `injectAtomValue` injector for v2
bowheart Jul 25, 2025
97b1ea9
docs: document `injectCallback` injector for v2
bowheart Jul 25, 2025
94d8f41
docs: document `injectEffect` injector for v2
bowheart Jul 31, 2025
e9e1309
docs: document `injectHydration` injector for v2
bowheart Aug 1, 2025
9b64c91
docs: document `injectMappedSignal` for v2
bowheart Aug 4, 2025
e261b14
docs: document `injectMemo` for v2
bowheart Aug 5, 2025
71368db
docs: document `injectPromise` for v2
bowheart Nov 7, 2025
6dbc2af
update /not-done injectPromise links
bowheart Nov 7, 2025
5b5d326
fix pnpm-lock zedux v1 peer deps
bowheart Nov 15, 2025
4ad17cc
docs: document `injectRef` for v2
bowheart Nov 15, 2025
0dd2766
update /not-done paths for `injectRef`
bowheart Nov 15, 2025
9bdb2c3
docs: document `injectSelf` for v2
bowheart Nov 15, 2025
efbe060
some tweaks
bowheart Nov 15, 2025
ec91a3a
docs: document `injectWhy` for v2
bowheart Nov 15, 2025
767885f
docs: document the `AtomConfig` type for v2
bowheart Nov 15, 2025
6f7583b
docs: document the new `inject` util
bowheart Nov 15, 2025
eca6cc0
docs: document the new `As` util
bowheart Nov 15, 2025
50a0921
docs: document the new `getDefaultEcosystem` util for v2
bowheart Nov 15, 2025
89cd2b2
docs: document `getInternals` for v2
bowheart Nov 15, 2025
3413f6a
docs: document `is` util for v2
bowheart Nov 16, 2025
2f720fc
docs: document `setInternals` for v2
bowheart Nov 16, 2025
6d61266
docs: document new `untrack` util
bowheart Nov 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: document the new getDefaultEcosystem util for v2
  • Loading branch information
bowheart committed Nov 15, 2025
commit 50a09219827167a8bd735b200b02aa557b527e72
19 changes: 9 additions & 10 deletions docs/docs/v2/api/classes/Ecosystem.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { createEcosystem } from '@zedux/react'
const rootEcosystem = createEcosystem({ id: 'root' })
```

Ecosystems are also created automatically when using an [`<EcosystemProvider>`](../components/EcosystemProvider) without passing an `ecosystem` prop:
Ecosystems are also created automatically when using an [`<EcosystemProvider>`](../components/EcosystemProvider.mdx) without passing an `ecosystem` prop:

```tsx
import { EcosystemProvider } from '@zedux/react'
Expand All @@ -44,15 +44,15 @@ function App() {

### Default Ecosystem

The [default ecosystem](../../../walkthrough/ecosystems#global) will be created automatically if atoms are used in React outside any `<EcosystemProvider>` or the first time you call [`getDefaultEcosystem()`](/not-done?path=../utils/getDefaultEcosystem).
The [default ecosystem](../../../walkthrough/ecosystems.mdx#global) will be created automatically if atoms are used in React outside any `<EcosystemProvider>` or the first time you call [`getDefaultEcosystem()`](../utils/getDefaultEcosystem.mdx).

The default ecosystem is great for simple apps. It's a full ecosystem, which means you can use features like [overrides](#overrides) and [ecosystem events](#events). However, it comes preconfigured with no (good) way to set config options like [`ssr`](#ssr) and [`onReady`](#onready).

It's generally recommended to create your own ecosystem(s) via [`createEcosystem()`](../factories/createEcosystem.mdx) and provide them to your app via [`<EcosystemProvider>`](../components/EcosystemProvider) instead of using the default ecosystem. This is especially needed for SSR.
It's generally recommended to create your own ecosystem(s) via [`createEcosystem()`](../factories/createEcosystem.mdx) and provide them to your app via [`<EcosystemProvider>`](../components/EcosystemProvider.mdx) instead of using the default ecosystem. This is especially needed for SSR.

## Providing

Ecosystems can take control of all atom usages in a React component tree by wrapping the tree in [`<EcosystemProvider>`](../components/EcosystemProvider).
Ecosystems can take control of all atom usages in a React component tree by wrapping the tree in [`<EcosystemProvider>`](../components/EcosystemProvider.mdx).

```tsx
function App() {
Expand Down Expand Up @@ -1091,12 +1091,11 @@ ecosystem.reset({ context: { redux: otherReduxStore } }) // replaces context

## See Also

- [the Ecosystems walkthrough](../../../walkthrough/ecosystems)
- [the Ecosystems walkthrough](../../../walkthrough/ecosystems.mdx)
- [the `createEcosystem()` factory](../factories/createEcosystem.mdx)
- [the Overrides walkthrough](../../../walkthrough/overrides)
- [the Plugins guide](../../../advanced/plugins)
- [`getDefaultEcosystem()`](/not-done?path=../utils/getDefaultEcosystem)
- [`setDefaultEcosystem()`](/not-done?path=../utils/setDefaultEcosystem)
- [the `<EcosystemProvider>` component](../components/EcosystemProvider)
- [the Overrides walkthrough](../../../walkthrough/overrides.mdx)
- [the Plugins guide](../../../advanced/plugins.mdx)
- [`getDefaultEcosystem()`](../utils/getDefaultEcosystem.mdx)
- [the `<EcosystemProvider>` component](../components/EcosystemProvider.mdx)
- [the `useEcosystem` hook](../hooks/useEcosystem.mdx)
- [the `injectEcosystem` injector](../injectors/injectEcosystem.mdx)
2 changes: 1 addition & 1 deletion docs/docs/v2/api/hooks/useEcosystem.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ function App() {

- [The `Ecosystem` class](../classes/Ecosystem.mdx)
- [The `<EcosystemProvider>` component](../components/EcosystemProvider.mdx)
- [The `getDefaultEcosystem()` utility](/not-done?path=../utils/getDefaultEcosystem.mdx)
- [The `getDefaultEcosystem` utility](../utils/getDefaultEcosystem.mdx)
46 changes: 46 additions & 0 deletions docs/docs/v2/api/utils/getDefaultEcosystem.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
id: getDefaultEcosystem
title: getDefaultEcosystem
---

import { Legend, Item, Link, Tabs, Ts, tab1, tab2 } from '@site/src/all'

```ts
import { getDefaultEcosystem } from '@zedux/react'
```

Returns the [default ecosystem](../classes/Ecosystem.mdx#default-ecosystem). Creates it if it doesn't exist yet.

## Example

```tsx live ecosystemId=example/getDefaultEcosystem resultVar=id version=2
import { getDefaultEcosystem } from '@zedux/react'

const ecosystem = getDefaultEcosystem()
const { id } = ecosystem
```

## Signature

<Tabs>
{tab1(`getDefaultEcosystem = () => Ecosystem`)}
{tab2(`declare const getDefaultEcosystem: () => Ecosystem<any>`)}
</Tabs>

<Legend>

<Item name="Returns">
An [Ecosystem](../classes/Ecosystem.mdx) instance.

The first time this is called, the default ecosystem will be created and cached in Zedux's module state. Subsequent calls will return the cached instance.
</Item>

</Legend>

## See Also

- [The Ecosystems walkthrough](../../../walkthrough/ecosystems.mdx)
- [The `Ecosystem` class](../classes/Ecosystem.mdx)
- [The `<EcosystemProvider>` component](../components/EcosystemProvider.mdx)
- [The `createEcosystem()` factory](../factories/createEcosystem.mdx)
- [The `useEcosystem()` hook](../hooks/useEcosystem.mdx)
6 changes: 5 additions & 1 deletion docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ module.exports = {
{
type: 'category',
label: 'Utils',
items: ['v2/api/utils/As', 'v2/api/utils/inject'],
items: [
'v2/api/utils/As',
'v2/api/utils/getDefaultEcosystem',
'v2/api/utils/inject',
],
},
'v2/api/glossary',
],
Expand Down