Hackder
TTCTheo's Typesafe Cult
•Created by Hackder on 7/13/2024 in #questions
Good react time picker
from all the reserach I did, this seems to be the only option, thanks
4 replies
TTCTheo's Typesafe Cult
•Created by Teapot on 7/13/2024 in #questions
How to handle Nextjs with external REST API
I am not really sure what exactly are you asking about.
When you are integrating an external API, you generaly have an "API key" which you can use to make requests to such api from your backend. (So yes, you will have to have a server action or an endpoint, which will make the API call)
If the API you are trying to use doesn't have a concept of an "API key", and you need to authenticate, it really depends on your situation. If you make these request often, you will need to store the JWT in the database, and revalidate it when necessary. I would try to avoid this tho. Make sure you can't use an API token, or if it's an external service that the user signs in, OAuth would make sense.
4 replies
TTCTheo's Typesafe Cult
•Created by Jacob on 6/25/2024 in #questions
Connecting to websockets in app router
Doing this highly depends on you deployment strategy. (If you want to subscribe on the server).
- If you deploy to vercel (or any lambda-like service), you will need to how a spearate application on something long running (container, VPS) that is going to preserve the connection. Your nextjs app will call this service and get the data as it needs. This is probably the best solution.
- If you are already deploying to your own server or a container, you can use the instrumentation hook in nextjs. It will run only once on server startup. You can create a subscription there and store it in a global variable to interact with it. This is also possible on serverless, but I would highly advise against it, because you will pay the connection cost on every cold start. (assuming you cannot respond to a request untinl the WS has been established.
5 replies