{"repo":"sweetscript/next-app-session","free":true,"listed":false,"github":"https://github.com/sweetscript/next-app-session","clone":"git clone https://github.com/sweetscript/next-app-session.git","description":"A Next.js App router secure server-side session library","language":"TypeScript","stars":27,"topics":["nextjs","session"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"Next-App-Session [!CAUTION] This package is no longer maintained, use https://unstorage.unjs.io/ instead --- This package is built to work with Next.js v13 App router and Server Components & Actions, additionally it also supports Pages router and middleware. This Next.js package enables secure storage of sessions in a server side store like express-session or redis or others, the package uses the next.js dynamic function cookies() to store the session id on the client side and that session id is then associated with user data on the server store. Package was inspired by express-session & next-session. Setup 1. Install package in your Next.js project 2. Create an initialisation file, for example: lib/session.ts , and write an exportable session variable like follows: 3. You can now use session() or session(req) in your App router & Page router i that order #### App router: Route Handler/Server Components/Server Actions #### Pages router/middleware: Note: in App router, session can only read data in Server Components while it can read+write data in Route Handler and Server Actions. It follows the same usage rules as the cookies() dynamic function A Router handler usage example: Page router usage example: --- Options Property Description Default :----------- :---------- :---------- name Name of the client cookie that holds the session ID 'sid' secret This is the secret used to sign the session cookie which will hold the user session ID. If left empty the session ID is not signed","default_branch":null,"files":null,"tree":[],"storefront":"/r/sweetscript","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sweetscript/next-app-session/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}