usling livekit sdk next js, is there an endpoint t...
# ask-ai
s
usling livekit sdk next js, is there an endpoint to stop the recording?
t
Thanks for reaching out, Mostafa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes — you can stop a recording from a Next.js app using the Node.js server SDK. Use
EgressClient.stopEgress(egressId)
from the
livekit-server-sdk
in a Next.js API route or other server-side code: 1. Install and import:
Copy code
import { EgressClient } from 'livekit-server-sdk';
1. Initialize:
Copy code
const egressClient = new EgressClient({
  apiKey: process.env.LIVEKIT_API_KEY!,
  apiSecret: process.env.LIVEKIT_API_SECRET!,
  host: process.env.LIVEKIT_HOST!,
});
1. Stop the recording:
Copy code
await egressClient.stopEgress(egressId);
If you’d like, share how you’re starting the egress (room composite, track, etc.) or the code you’re using and I’ll give an example API route tailored to your setup. Sources: server-sdk-js | livekit/livekit_composite | DeepWiki
s
and shutdown the room will end the egrees too right ?
t
Yes — shutting down (deleting) the room will end any ongoing egress (recording/streaming) tied to that room. Deleting the room removes all participants (including the hidden egress participant), which stops recordings and helps avoid leftover audio/video artifacts. If you want, tell me whether you prefer to: • delete the room when the session ends, or • stop egress explicitly with
EgressClient.stopEgress(egressId)
and I’ll provide the exact Next.js API route or steps for that approach.