If you’re planning on using Pinata inside of a web application, this template is a great way to get started. Pinata uses the builtin Next.js api routes to keep your API keys secure, and we make it easy to spin up!

Getting Started

API Keys and Gateway

If you haven’t already, visit the keys page and create an API key.

You can also use your own Dedicated Gateway domain, which you can get from the Gateways page.

Starting Up the App

Create a new Pinata project using this command:

npx create-pinata-app

Follow the prompts in the command line to create the project. Once complete, change into the new project directory and run the app with the following command:

npm run dev

You can edit the pages/index.js file and the API route file pages/api/files to see the Pinata functionality and extend it or make changes.

Environment Variables

This project makes use of both public and private environment variables. The private environment variables are used to protect sensitive data like your Pinata API keys. The public environment variables are convenient central variable housing.

Read more about how environment variables work with Next.js here.

There is a .env.sample file you can copy and rename to .env.local for use in your project. Be sure to fill out the environment variable values in the .env.local file with your actual values.

Learn More

For more information about building apps with Pinata and IPFS, check out the following resources: