Skip to content

Commit 08c3345

Browse files
committed
📘 doc: remove redundant section
1 parent 9449e74 commit 08c3345

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

docs/essential/plugin.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -155,36 +155,10 @@ We can use the plugin by passing an instance to **Elysia.use**.
155155

156156
<Playground :elysia="demo1" />
157157

158-
The plugin will inherit all properties of the plugin instance like `state`, `decorate` but **WILL NOT inherit plugin lifecycle** as it's [isolated by default](#scope).
158+
The plugin will inherit all properties of the plugin instance like `state`, `decorate` but **WILL NOT inherit plugin lifecycle** as it's [isolated by default](#scope) (mentioned in the next section ↓).
159159

160160
Elysia will also handle the type inference automatically as well.
161161

162-
## Plugin
163-
164-
Every Elysia instance can be a plugin.
165-
166-
We decouple our logic into a separate Elysia instance and reuse it across multiple instances.
167-
168-
To create a plugin, simply define an instance in a separate file:
169-
```typescript twoslash
170-
// plugin.ts
171-
import { Elysia } from 'elysia'
172-
173-
export const plugin = new Elysia()
174-
.get('/plugin', () => 'hi')
175-
```
176-
177-
And then we import the instance into the main file:
178-
```typescript
179-
import { Elysia } from 'elysia'
180-
import { plugin } from './plugin' // [!code ++]
181-
182-
const app = new Elysia()
183-
.use(plugin) // [!code ++]
184-
.listen(3000)
185-
```
186-
187-
188162
## Scope
189163

190164
Elysia lifecycle methods are **encapsulated** to its own instance only.

0 commit comments

Comments
 (0)