Skip to content

parkgang/trpc-iron-session

Repository files navigation

trpc-iron-session

English | 한국어(KR)

Secure your tRPC based on iron-session authentication.

The project structure is based on iron-session examples next.js-typescript

Changed the HTTP API part to tRPC without changing the project structure as much as possible.

Thanks to this, if you pour iron-session examples next.js-typescript here as it is, it will diff so you can easily see the changes.

that the SSG page in the example is meaningless because of the SSR option of tRPC. 🙄

Start

npm i
npm run dev

Core

Forwarding SSR Cookies

If you are logged in through SSR , you may want to quickly display user information in the <Header /> .

To do this, you need to pass cookies to tRPC during SSR.

Please refer to src/utils/trpc.ts for the related code.

Passing iron-session value to tRPC Context

If you are familiar with iron-session, we will use the req.session to manipulate cookies.

tRPC must be passed as a Context to achieve this.

Please refer to src/server/context.ts for the related code.

Reference

Projects used for scaffolding

About

Secure your tRPC based on iron session authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published