@@ -614,6 +614,88 @@ app.listen(3000, (token) => {
614
614
615
615
Reference: https://github.com/uNetworking/uWebSockets.js
616
616
617
+ ### With Hono (Node.js)
618
+
619
+ <Tabs groupId =" lang " >
620
+ <TabItem value =" cjs " label =" CommonJS " default >
621
+
622
+ ``` js
623
+ const { Hono } = require (" hono" );
624
+ const { serve } = require (" @hono/node-server" );
625
+ const { Server } = require (" socket.io" );
626
+
627
+ const app = new Hono ();
628
+
629
+ const httpServer = serve ({
630
+ fetch: app .fetch ,
631
+ port: 3000 ,
632
+ });
633
+
634
+ const io = new Server (httpServer, {
635
+ /* options */
636
+ });
637
+
638
+ io .on (" connection" , (socket ) => {
639
+ // ...
640
+ });
641
+ ```
642
+
643
+ </TabItem >
644
+ <TabItem value =" mjs " label =" ES modules " >
645
+
646
+ ``` js
647
+ import { Hono } from " hono" ;
648
+ import { serve } from " @hono/node-server" ;
649
+ import { Server } from " socket.io" ;
650
+
651
+ const app = new Hono ();
652
+
653
+ const httpServer = serve ({
654
+ fetch: app .fetch ,
655
+ port: 3000 ,
656
+ });
657
+
658
+ const io = new Server (httpServer, {
659
+ /* options */
660
+ });
661
+
662
+ io .on (" connection" , (socket ) => {
663
+ // ...
664
+ });
665
+ ```
666
+
667
+ </TabItem >
668
+ <TabItem value =" ts " label =" TypeScript " >
669
+
670
+ ``` ts
671
+ import { Hono } from " hono" ;
672
+ import { serve } from " @hono/node-server" ;
673
+ import { Server } from " socket.io" ;
674
+ import type { Server as HTTPServer } from " node:http" ;
675
+
676
+ const app = new Hono ();
677
+
678
+ const httpServer = serve ({
679
+ fetch: app .fetch ,
680
+ port: 3000 ,
681
+ });
682
+
683
+ const io = new Server (httpServer as HTTPServer , {
684
+ /* options */
685
+ });
686
+
687
+ io .on (" connection" , (socket ) => {
688
+ // ...
689
+ });
690
+
691
+ ```
692
+
693
+ </TabItem >
694
+ </Tabs >
695
+
696
+ More information [ here] ( https://hono.dev ) .
697
+
698
+
617
699
## Options
618
700
619
701
The complete list of available options can be found [ here] ( ../../server-options.md ) .
0 commit comments