This sample project covers:
- Setting up ImageKit React SDK
- Rendering images
- Setting authentication context for the SDK
- Applying common image manipulations
- Adding overlays to images
- Lazy loading images
- Blurred image placeholder
- Client-side file uploading
- Rendering videos
yarn install
OR
npm install
In src/App.js
, set the following parameters for authentication:
const publicKey = '<YOUR_IMAGEKIT_PUBLIC_KEY>';
const urlEndpoint = '<YOUR_IMAGEKIT_URL_ENDPOINT>';
// only needed if you want to use the SDK for client-side file upload
const authenticator = ()=>{
return new Promise((resolve,reject)=>{
resolve({signature,token,expiry})
})
};
Required parameters are urlEndpoint
and publicKey
. The authenticator
parameter is optional and only needed if you want to use the SDK for client-side file upload.
You can get the value of URL-endpoint from your ImageKit dashboard. API public key can be obtained from the developer section in your ImageKit dashboard.
yarn start
OR
npm start
Open the page at http://localhost:3000
.
Set the following keys in server/index.js
const imagekit = new ImageKit({
urlEndpoint: '<YOUR_IMAGEKIT_URL_ENDPOINT>',
publicKey: '<YOUR_IMAGEKIT_PUBLIC_KEY>',
privateKey: '<YOUR_IMAGEKIT_PRIVATE_KEY>',
});
All these parameters are required. API private key can also be obtained from the developer section in your ImageKit dashboard.
Please note that file upload will only work if, along with the above, you have also defined YOUR_IMAGEKIT_PUBLIC_KEY
, YOUR_IMAGEKIT_URL_ENDPOINT
, and YOUR_AUTHENTICATOR_FUNCTION
variables in src/App.js
.
cd server
node index.js
Node server will run at http://localhost:3001
.
- React quickstart guide - https://docs.imagekit.io/getting-started/quickstart-guides/react
- React SDK and documentation - https://github.com/imagekit-developer/imagekit-react
If something doesn't work as expected, report a bug at support@imagekit.io.
This project was bootstrapped with Create React App.