MikanDev Images
- MikanDev Images is a simple API tat optimizes images, and delivers them through a CDN.
- This is primarily for dynamically rendering images when using static site generators, but can be used for other purposes as well :)
Hosted API
- Endpoint:
https://images.mikandev.tech/
- This public API is free to use, and is accellerated with BunnyCDN.
- Once an image is generated once, it is cached for one month and is not regenerated with the same parameters until then.
Experimental Endpoints
- Endpoint 2:
https://aws.images.mikandev.tech/
- This API works the same as the hosted API, but is accelerated with AWS CloudFront.
Caching policy
Images are cached for one year, and are not regenerated with the same parameters until then.
API Usage
- Replace
(URL)
with the URL of the image you want to generate. - Replace
(width)
with the width of the image you want to generate.
The API will return an image with the specified width.
NextJS Integration
- This API can be used with NextJS by using the
Image
component. All that is required is a custom loader file. - This may be useful when using NextJS static exports, as NextJS doesn’t natively support image optimization when exporting statically.
- You could also use it in a fullstack deployment to reduce load on your origin server.
Example
- Create a file named
loader.ts
in the root of your project, and add the following code:
- Make sure to replace
(baseUrl)
with the base URL of your project.
- Add the following lines to your NextConfig file:
- Enjoy :)