How can I set up @sanity/client
on both vercel and a local development? Right now we have it set up on vercel, but I would like to do some local development on the site, but I don't know how to set up the environment variables on my local machine.
This is how the code looks right now on our site. This is the code for @sanity/client
:
import sanityClient from "@sanity/client";
import { config } from "@/utils/config";
const client = sanityClient({
projectId: config.sanityProjectId,
dataset: config.sanityProjectDataset,
token: config.sanityProjectToken,
useCdn: false,
ignoreBrowserTokenWarning: true,
});
export default client;
And here is the relevant code from the config file:
import getConfig from "next/config";
// Only holds serverRuntimeConfig and publicRuntimeConfig
const { publicRuntimeConfig } = getConfig();
export const config = {
sanityProjectId: publicRuntimeConfig?.sanityProjectId,
sanityProjectDataset: publicRuntimeConfig?.sanityProjectDataset,
sanityProjectToken: publicRuntimeConfig?.sanityProjectToken,
};
Any idea how I can set this up so that it will work also on my local computer?