Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Netx.js support? #1340

Open
miguelbogota opened this issue Oct 26, 2023 · 1 comment
Open

[Question] Netx.js support? #1340

miguelbogota opened this issue Oct 26, 2023 · 1 comment

Comments

@miguelbogota
Copy link

I'm currently working in a simple game and I want to implement a multiplayer mode. I would like to use Gun however I had found the documentation lacking on trending frameworks like Next.js, Solid, Qwik, ect... I tried to use it in a Next app just like the documentation said but I was bombed with a lot of issues in the terminal. I figured that the server and client versions were getting conflicted so I just add the scrips to the app like so:

Next.js 13

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        <script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/gun/axe.js"></script>
      </head>
      <body>{children}</body>
    </html>
  );
}

And augment the type definitions for typescript. This worked but another set of errors popped up.

WebSocket connection to 'ws://localhost:8765/gun' failed: 
WebSocket connection to 'ws://localhost:4000/gun' failed: 

I saw this other issue #1278 and it seems like I need to create a peer server but I and link the client and server for them to work. However, I do not want to create a single file for a server and every time I run my app run another terminar with the dev server or install unneeded dependencies to run 2 commands at the same time. I would like to use a Next.js api route to create the relay server but I do not know how to.

Can somebody help me to figure this out?

@gustavcorpas
Copy link

Hello fellow gun-enthusiast.
I think we should keep the issues tab, for actual issues.

Consider asking questions over at: the gitter. The people there are usually very helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants