universal-authentication implementation on top of trpc
npm install @universal-packages/trpc-authentication
Initialize the authentication api configuration for the authentication trpc routers.
import { initialize } from '@universal-packages/trpc-authentication'
await initialize({ secret: 'my-secret' })
initialize
takes the same options as Authentication
.
Create a trpc router with the authentication methods.
import { initTRPC } from '@trpc/server'
import { createAuthenticationRouter, initialize } from '@universal-packages/trpc-authentication'
await initialize({ secret: 'my-secret' })
export const trpc = initTRPC.create()
export const appRouter = trpc.router({
authentication: createAuthenticationRouter(trpc)
})
Create a trpc router with the default authentication module methods. You usually want to combine the base router with other modules.
import { initTRPC } from '@trpc/server'
import { createAuthenticationRouter, createDefaultAuthenticationModuleRouter, initialize } from '@universal-packages/trpc-authentication'
export const trpc = initTRPC.create()
export const appRouter = trpc.router({
authentication: trpc.mergeRouters(createAuthenticationRouter(trpc), createDefaultAuthenticationModuleRouter(trpc))
})
This library is developed in TypeScript and shipped fully typed.
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.