Skip to content

Commit 267826e

Browse files
committed
feat: add isBot and tweak
1 parent 0035fa6 commit 267826e

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

package-lock.json

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@types/react-dom": "^18.3.0",
3939
"eslint": "^8.57.0",
4040
"hono": "^4.5.11",
41+
"isbot": "^5.1.17",
4142
"np": "^10.0.7",
4243
"publint": "^0.2.10",
4344
"react": "^18.3.1",
@@ -46,12 +47,13 @@
4647
"vitest": "1.5.0"
4748
},
4849
"peerDependencies": {
49-
"@remix-run/react": "^2.11.2",
50+
"@remix-run/react": ">=2.0.0",
51+
"isbot": ">=5.0.0",
5052
"hono": "*",
51-
"react": "^18.3.1",
52-
"react-dom": "^18.3.1"
53+
"react": ">=18.0.0",
54+
"react-dom": ">=18.0.0"
5355
},
5456
"engines": {
5557
"node": ">=18.0.0"
5658
}
57-
}
59+
}

src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { handle } from './index'
2-
import { describe, expect, it } from 'vitest'
31
import type { EntryContext } from '@remix-run/cloudflare'
42
import { Hono } from 'hono'
3+
import { describe, expect, it } from 'vitest'
4+
import { handle } from './index'
55

66
describe('Basic', () => {
77
it('Should return 200 response with the mock context', async () => {

src/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { EntryContext } from '@remix-run/cloudflare'
2+
import { RemixServer } from '@remix-run/react'
3+
import { Hono } from 'hono'
4+
import { isbot } from 'isbot'
25
// @ts-expect-error `react-dom/server.browser` is not typed
36
import { renderToReadableStream } from 'react-dom/server.browser'
4-
import { Hono } from 'hono'
5-
import { RemixServer } from '@remix-run/react'
67

78
export const handle =
89
(userApp?: Hono) =>
@@ -36,6 +37,11 @@ export const handle =
3637
},
3738
}
3839
)
40+
41+
if (isbot(request.headers.get('user-agent') || '')) {
42+
await body.allReady
43+
}
44+
3945
c.header('Content-Type', 'text/html')
4046
return c.body(body, {
4147
status: c.env.responseStatusCode,

0 commit comments

Comments
 (0)