Add keyshade to your project
Start using keyshade in your project
Last updated
Was this helpful?
Start using keyshade in your project
Last updated
Was this helpful?
We would be using a Next.js project to demonstrate the process. First, we will be setting up the project, then we would be using our CLI to tie up keyshade to the project.
Create a NextJS app and name it my-app
. Keep everything to default, and make sure that the app is using TypeScript.
Use this command to create a Next.js project:
You can find more info about creating a Next.js project .
main.ts
fileIn the my-app
directory, open the main.ts
file and add the following code:
As you can see, we are using 2 environment variables:
NEXT_PUBLIC_API_KEY
NEXT_PUBLIC_PORT
Run the following command to initialize keyshade in your project:
This is an interactive command, and will ask you to input the workspace-slug
, project-slug
, environment-slug
and private-key
to create the keyshade.json
file in your project root directory.
You could alternatively run this command to add everything in one line:
You would notice that the keyshade.json
file has been created in your project root directory. The content would look something like this:
Your project's private key has been added into ~/.keyshade/private-keys.json
. This approach makes it impossible for you to mistakenly commit your private key to your repository.
We have not added these in any .env
file. If you recall, we added these to our project in the section.