Next.js Discord

Discord Forum

https://vercel.com/guides/session-store-nextjs-redis-vercel-kv

Unanswered
American Kestrel posted this in #help-forum
Open in Discord
Avatar
American KestrelOP
https://vercel.com/guides/session-store-nextjs-redis-vercel-kv
In this link, all the code that's given, except for the last block, where do I add it? the functions for getSessionId, setSessionId, get, getAll, set, etc.

I have a next.js 13.4 repo

Should I add it in my api/<whatever>/route.ts?

11 Replies

Avatar
tafutada777
i guess you can define them in ./session-store file. 1, 2 3 can sit in the same file i guess.
so you can grab them
import { get, set, getSessionId } from './session-store';
obviously it accesses cookie and kv, so it works in server side codes only. it does not work in client side codes.
Avatar
American KestrelOP
Oh! Ok!
Avatar
American KestrelOP
Hi, another doubt
this happens
Image
when I've cleared commented it out
Image
Avatar
tafutada777
u need to specify http part. like https://www.something.com/api/youtube
Avatar
American KestrelOP
but what if we're running locally
Avatar
tafutada777
http://localhost/api/youtube
but calling yourself is not recommended.
Avatar
American KestrelOP
If I want to make two separate API calls to POST under api/youtube
how can I do that?

should I just make two different folders
api/youtube1
api/youtube2