Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Support For t3-app Next js 14 with app router #442

Open
mude-albij opened this issue Mar 11, 2024 · 5 comments
Open

Support For t3-app Next js 14 with app router #442

mude-albij opened this issue Mar 11, 2024 · 5 comments

Comments

@mude-albij
Copy link

Greeting, I am using t3-app with next js 14 and app router. i've setup the trpc-openapi for OpenAPI but can't get the adapters working and is not clarified in the docs.

@Vercjames
Copy link

Vercjames commented Mar 25, 2024

Forked and Added support for Next.js 14.
https://github.com/Vercjames/package-trpc-swagger

@kdy1
Copy link

kdy1 commented Apr 14, 2024

I made https://www.npmjs.com/package/next-trpc-openapi

@sutarrohit
Copy link

Screenshot from 2024-05-01 09-06-44
I don't know why i am getting this error.
i am using t3-app with next js 14 and app router.

@Pridestalkerr
Copy link

@sutarrohit pretty sure that error happens because you're using tRPC v11. Either downgrade back to v10 (recommended if you really need the library) or you can do something like this (where you define your router):

const appRouter = router({
  test: testRouter,
  auth: authRouter,
});

const procedures = appRouter._def.procedures;
Object.keys(procedures).forEach((key) => {
  const def = (procedures[key as keyof typeof procedures] as unknown as AnyProcedure)?._def;
  // @ts-expect-error: internal API
  if (def?.meta?.openapi) {
    switch (def.type) {
      case "query":
        // @ts-expect-error: unstable support for tRPC v11
        def.query = true;
        break;
      case "mutation":
        // @ts-expect-error: unstable support for tRPC v11
        def.mutation = true;
        break;
      case "subscription":
        // @ts-expect-error: unstable support for tRPC v11
        def.subscription = true;
        break;
    }
  }
});

export { appRouter };

This is something I've been doing and it seems to work but it is in no way stable and I would not recommend running it in production.

@mude-albij
Copy link
Author

@Pridestalkerr thanks definitely check for your solution

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

No branches or pull requests

5 participants