iway1 / trpc-panel

MIT License
663 stars 50 forks source link

feat: add app router example on readme.md #88

Open itelo opened 1 year ago

tomassabol commented 1 year ago

Hi, I tried searching for issues related to app router and found this one. I tried the solution suggested in your commit, but it did not work. Luckily, I managed to get it working using this:

import { renderTrpcPanel } from "trpc-panel";
import { appRouter } from "~/server/routers/_app";

const panelHandler = () => {
  return new Response(
    renderTrpcPanel(appRouter, {
      url: "http://localhost:3000/api/trpc",
      transformer: "superjson",
    }),
    {
      headers: { "Content-Type": "text/html" },
    }
  );
};

export { panelHandler as GET, panelHandler as POST };

Location of the file is the same as you used, src/app/api/panel/route.ts

Hope this helps

itelo commented 1 year ago

Hey @tomassabol, the only change was on the appRouter import? I believe it's okay not to be 100% accurate because the appRouter location could change depending on where the user puts it.

tomassabol commented 1 year ago

Yes, the import is individual. The main thing I changed is the export, and export types.

joshy36 commented 1 year ago

@itelo @tomassabol anyone get {"name":"TRPCClientError"} error when trying to make a query or mutation?

tomassabol commented 1 year ago

@itelo @tomassabol anyone get {"name":"TRPCClientError"} error when trying to make a query or mutation?

Unfortunately yes. I am getting this error on every endpoint using this implementation, but when I tried using this experimental repo, it worked flawlessly

joshy36 commented 1 year ago

ok thanks for letting me know

joshy36 commented 1 year ago

Im probably gonna just wait until they support the app router lol and keep using the first implementation for now