.env
Answered
Sun bear posted this in #help-forum
Sun bearOP
is that code okay:
import Ably from "ably";
export default async function subscribeAbly(callback: (data: any) => void) {
const ably = new Ably.Realtime.Promise(
"kF6GTQ.ghESTw:4"
);
await ably.connection.once("connected");
const channel = ably.channels.get("chat");
await channel.subscribe("message", (message: { data: any }) => {
callback(message.data);
});
}Answered by European sprat
If this is a server component put the key in .env and access it in the server component with process.env.yourkeyname if it's a client component and the key needs to be exposed to the client then you can prefix it with
NEXT_PUBLIC_ in .env5 Replies
Sun bearOP
i mean key is open
to everyone
European sprat
If this is a server component put the key in .env and access it in the server component with process.env.yourkeyname if it's a client component and the key needs to be exposed to the client then you can prefix it with
NEXT_PUBLIC_ in .envAnswer