Skip to content

Commit 18f0cc7

Browse files
committed
docs(create-trinity): add Plugin Trinity section pointing to createPluginContext as preferred pattern
1 parent 4a6d0f4 commit 18f0cc7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

apps/docs/src/pages/composables/foundation/create-trinity.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ flowchart LR
8282
C --> Fallback
8383
```
8484

85+
## Plugin Trinity
86+
87+
When building a Vue plugin, use [`createPluginContext`](/composables/foundation/create-plugin) instead of wiring `createContext + createTrinity` manually. It generates the same trinity tuple from a factory function with far less boilerplate:
88+
89+
```ts no-filename
90+
// Manual (createTrinity) — needed for non-plugin state
91+
export const [useUser, provideUser, userContext] = createUserContext()
92+
93+
// Plugin (createPluginContext) — preferred for app.use() plugins
94+
export const [createThemeContext, createThemePlugin, useTheme] =
95+
createPluginContext('v0:theme', options => createTheme(options))
96+
```
97+
98+
`createTrinity` is the right tool when you want a shared singleton *without* a Vue plugin — component-scoped contexts, library utilities, or any state that doesn't need `app.use()` lifecycle hooks.
99+
85100
## Examples
86101

87102
::: example

0 commit comments

Comments
 (0)