Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/react-router-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"evlog": minor
---

Add React Router middleware integration (`evlog/react-router`) with automatic wide-event logging, drain, enrich, and tail sampling support
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Here are the available types and scopes:
- elysia (Elysia plugin)
- fastify (Fastify plugin)
- nestjs (NestJS middleware)
- react-router (React Router integration)
- sveltekit (SvelteKit integration)
- workers (Cloudflare Workers adapter)
- fs (File System adapter)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
elysia
fastify
nestjs
react-router
sveltekit
workers
fs
Expand Down
30 changes: 17 additions & 13 deletions apps/docs/app/components/features/FeatureFrameworks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ const frameworkRows = [
{ name: 'SvelteKit', icon: 'i-simple-icons-svelte', tab: 2 },
{ name: 'Nitro', icon: 'i-custom-nitro', tab: 3 },
{ name: 'TanStack Start', icon: 'i-custom-tanstack', tab: 4 },
{ name: 'NestJS', icon: 'i-simple-icons-nestjs', tab: 5 },
{ name: 'React Router', icon: 'i-simple-icons-reactrouter', tab: 5 },
{ name: 'NestJS', icon: 'i-simple-icons-nestjs', tab: 6 },
],
[
{ name: 'Express', icon: 'i-simple-icons-express', tab: 6 },
{ name: 'Hono', icon: 'i-simple-icons-hono', tab: 7 },
{ name: 'Fastify', icon: 'i-simple-icons-fastify', tab: 8 },
{ name: 'Elysia', icon: 'i-custom-elysia', tab: 9 },
{ name: 'Cloudflare', icon: 'i-simple-icons-cloudflare', tab: 10 },
{ name: 'Bun', icon: 'i-simple-icons-bun', tab: 11 },
{ name: 'Express', icon: 'i-simple-icons-express', tab: 7 },
{ name: 'Hono', icon: 'i-simple-icons-hono', tab: 8 },
{ name: 'Fastify', icon: 'i-simple-icons-fastify', tab: 9 },
{ name: 'Elysia', icon: 'i-custom-elysia', tab: 10 },
{ name: 'Cloudflare', icon: 'i-simple-icons-cloudflare', tab: 11 },
{ name: 'Bun', icon: 'i-simple-icons-bun', tab: 12 },
{ name: 'Vite', icon: 'i-custom-vite', link: '/core-concepts/vite-plugin' },
],
]
Expand Down Expand Up @@ -129,24 +130,27 @@ const frameworkRows = [
<slot name="tanstack-start" />
</div>
<div v-show="activeTab === 5" class="landing-code">
<slot name="nestjs" />
<slot name="react-router" />
</div>
<div v-show="activeTab === 6" class="landing-code">
<slot name="express" />
<slot name="nestjs" />
</div>
<div v-show="activeTab === 7" class="landing-code">
<slot name="hono" />
<slot name="express" />
</div>
<div v-show="activeTab === 8" class="landing-code">
<slot name="fastify" />
<slot name="hono" />
</div>
<div v-show="activeTab === 9" class="landing-code">
<slot name="elysia" />
<slot name="fastify" />
</div>
<div v-show="activeTab === 10" class="landing-code">
<slot name="cloudflare" />
<slot name="elysia" />
</div>
<div v-show="activeTab === 11" class="landing-code">
<slot name="cloudflare" />
</div>
<div v-show="activeTab === 12" class="landing-code">
<slot name="bun" />
</div>
</Motion>
Expand Down
28 changes: 28 additions & 0 deletions apps/docs/content/0.landing.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,34 @@ Wide events and structured errors for TypeScript. One log per request, full cont
})
```

#react-router
```ts [app/routes/api.checkout.tsx]
import { loggerContext } from 'evlog/react-router'
import { createError } from 'evlog'

export async function action({ request, context }: Route.ActionArgs) {
const log = context.get(loggerContext)
const { cartId } = await request.json()

const cart = await db.findCart(cartId)
log.set({ cart: { items: cart.items.length, total: cart.total } })

const charge = await stripe.charge(cart.total)
log.set({ stripe: { chargeId: charge.id } })

if (!charge.success) {
throw createError({
status: 402,
message: 'Payment failed',
why: charge.decline_reason,
fix: 'Try a different payment method',
})
}

return Response.json({ orderId: charge.id })
}
```

#nestjs
```ts [app.module.ts]
import { Module } from '@nestjs/common'
Expand Down
9 changes: 9 additions & 0 deletions apps/docs/content/1.getting-started/2.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ After installing the package, follow the setup guide for your framework:
:::
:::card
---
icon: i-simple-icons-reactrouter
title: React Router
to: /frameworks/react-router
color: neutral
---
Middleware with `context.get(loggerContext)`.
:::
:::card
---
icon: i-simple-icons-nestjs
title: NestJS
to: /frameworks/nestjs
Expand Down
10 changes: 10 additions & 0 deletions apps/docs/content/2.frameworks/00.overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ evlog provides native integrations for every major TypeScript framework. The sam
| [SvelteKit](/frameworks/sveltekit) | `evlog/sveltekit` | Hooks | `event.locals.log` / `useLogger()` | Stable |
| [Nitro](/frameworks/nitro) | `evlog/nitro` | Module | `useLogger(event)` | Stable |
| [TanStack Start](/frameworks/tanstack-start) | `evlog/nitro/v3` | Module | `useRequest().context.log` | Stable |
| [React Router](/frameworks/react-router) | `evlog/react-router` | Middleware | `context.get(loggerContext)` / `useLogger()` | Stable |
| [NestJS](/frameworks/nestjs) | `evlog/nestjs` | Module | `useLogger()` | Stable |
| [Express](/frameworks/express) | `evlog/express` | Middleware | `req.log` / `useLogger()` | Stable |
| [Hono](/frameworks/hono) | `evlog/hono` | Middleware | `c.get('log')` | Stable |
Expand Down Expand Up @@ -77,6 +78,15 @@ evlog provides native integrations for every major TypeScript framework. The sam
:::
:::card
---
icon: i-simple-icons-reactrouter
title: React Router
to: /frameworks/react-router
color: neutral
---
Middleware with `context.get(loggerContext)` and `useLogger()` for loaders and services.
:::
:::card
---
icon: i-simple-icons-nestjs
title: NestJS
to: /frameworks/nestjs
Expand Down
Loading
Loading