Skip to content

Usage with TRPC? (Combining with server code) #52

@pat-mw

Description

@pat-mw

Hi there!

Really pleased to have stumbled on this template, as it has shown me a path forward for integrating more complex features into my site where I was previously considering using Wized or porting my entire application to React using Devlink.

I am a programmer at heart, so whilst Wized is very appealing - I prefer the flexibility that managing my own codebase allows, especially when it comes to integrations with other services.

---- INTRO ----

With NodeJS servers, my approach recently has been to use TRPC. TRPC offers a typescript-safe way of handling requests from client to server. It is part of the T3 Stack for NextJS (create-t3-app) which I have become very familiar with.

Whilst the set up is a little bit of a pain, the end result is a really smooth DX when making requests to my server and parsing the response.

Rather than writing convoluted functions that use fetch/axios, and then parsing JSON and defining my types manually - TRPC abstracts away all the complexities and offers typehinting and server calls with a single line of code.

---- PROBLEM ----

I have set up my TRPC server according to the official documentation, and then set up my vanilla client according to the following guide: https://trpc.io/docs/client/vanilla

However, I am having issues getting this to actually work within the finsweet developer starter boilerplate.

My scripts are correctly registered, and are running as expected within Webflow, but I am getting the following error in the console whenever I make a request using trpc:

image

The 404 error seems to suggest that the trpc server isn't actually running, despite typehinting working on my client, and no errors in the trpc configurations.

---- CLOSING ----

I would appreciate some guidance on integrating TRPC. Under the hood, it should be no different to fetch requests so I am not sure what I am doing wrong - perhaps there is extra configuration needed to actually set up the server, which I am missing.

I would be happy to share access to my repo if this would help.

Thanks in advance for any guidance you can provide!

Best,
Patrick

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions