Coder Social home page Coder Social logo

icflorescu / trpc-sveltekit-example Goto Github PK

View Code? Open in Web Editor NEW
131.0 4.0 19.0 821 KB

A sample SvelteKit application built to illustrate the usage of ✨ trpc-sveltekit.

Home Page: https://icflorescu.github.io/trpc-sveltekit

License: ISC License

JavaScript 1.60% HTML 0.52% TypeScript 34.04% Svelte 63.84%
example prisma svelte sveltekit trpc typescript

trpc-sveltekit-example's Introduction

😎 tRPC-SvelteKit example: Bookstall

License Sponsor the author

A sample SvelteKit application built to illustrate the usage of trpc-sveltekit.

Screenshot

tRPC-SvelteKit Example: Bookstall

Acknowledgements

Huge thanks to Alex / KATT, for bringing us tRPC and for being the first sponsor of tRPC-SvelteKit! 🎉

License

The ISC License.

trpc-sveltekit-example's People

Contributors

calvin-mclain avatar fractal-tess avatar icflorescu avatar irflorescu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

trpc-sveltekit-example's Issues

upload file

Hi @icflorescu thanks for the clear example.
Do you have any plan (to add example) or idea on how to do file/image uploading?

Thank you

First request running twice

Right now, visiting a page that has a trpc query in it's load function (ex. /authors) , will result in that trpc query running twice. First on the server, then again on the client. This is happening (I think) because we're not using the fetch provided by load.

Note: This is only applicable to the first request, since all other requests after that are client side only.

There two ways to go around this issue:

  1. Move the trpc query from load to a page endpoint.
  2. Find a way to make trpc use the fetch provided by load. No idea how.

This would ensure that the request would not happen twice. It would happen only on the server.

From the docs:

When fetch runs on the server, the resulting response will be serialized and inlined into the rendered HTML. This allows the subsequent client-side load to access identical data immediately without an additional network request.

pnpm doesn't work

Oddly this doesn't happen with yarn and npm.
After installing with pnpm I get the following error:

image

Any ideas?

adding authentication

i remember having a lot of trouble to add auth in my app using this library (because of the cookies). i was able to get it to work, but after the recent sveltekit update (which removed the session store) im having a lot of trouble to get it to work

it would be nice to showcase authentication via cookies in this example

Question: Why is the trpc client initialized multiple times in the `.svelte` files?

I apologize if this is a dumb question, but I am quite new to tRPC and still trying to figure stuff out. Why, in every method in the .svelte templates is the trpc client invoked for each query, mutation, etc? Eg,

const reloadBooks = async () => {
  loading = true;
  data.books = await trpc().query('books:browse', query);
  loading = false;
};

This doesn't seem to be a thing in the server code, where trpc() is invoked once and is then reused mutiple times. Won't doing that work in the client code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.