
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
imagekitio-vue
Advanced tools
[](https://github.com/imagekit-developer/imagekit-vuejs/) [](https://www.npmjs.com/package/imagekitio-
Vue SDK for ImageKit.io, which implements client-side upload and URL generation for use inside a vue application.
ImageKit is a complete image optimization and transformation solution that comes with an image CDN and media storage. It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
npm install --save imagekitio-vue
Include the components in your code:
import {IKContext} from "imagekitio-vue"
The library includes 3 Components:
In order to use the SDK, you need to provide it with a few configuration parameters. The configuration parameters can be applied directly to the Image
component or using an IKContext
component. example:
<IKContext
publicKey="your_public_api_key"
urlEndpoint="<https://ik.imagekit.io/your_imagekit_id>">
<IKImage src="<full_image_url_from_db>"/>
</IKContext>
publicKey
and urlEndpoint
are mandatory parameters for SDK initialization.
authenticationEndpoint
is essential if you want to use the SDK for client-side uploads.
transformationPosition
is optional. The default value for this parameter is path
. Acceptable values are path
& query
Note: Do not include your Private Key in any client-side code, including this SDK or its initialization. If you pass the privateKey
parameter while initializing this SDK, it throws an error
The image component defines an IKImage tag. Example usage:
<IKImage
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/your_imagekit_id"
path="/path_to_file"/>
<IKImage
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/your_imagekit_id"
src="<full_image_url_from_db>"/>'
Option | Description |
---|---|
urlEndpoint | Optional. The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ |
path | Conditional. This is the path at which the image exists. For example, /path/to/image.jpg . Either the path or src parameter need to be specified for URL generation. |
src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg . Either the path or src parameter need to be specified for URL generation. |
transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a chained transformation can be specified as different objects of the array. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. |
transformationPostion | Optional. The default value is path that places the transformation string as a path parameter in the URL. It can also be specified as query which adds the transformation string as the query parameter tr in the URL. If you use src parameter to create the URL, then the transformation string is always added as a query parameter. |
queryParameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameter to your URLs. |
The complete list of transformations supported and their usage in ImageKit can be found here. The SDK gives a name to each transformation parameter, making the code simpler and readable. If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using in the url
function.
Supported Transformation Name | Translates to parameter |
---|---|
height | h |
width | w |
aspectRatio | ar |
quality | q |
crop | c |
cropMode | cm |
x | x |
y | y |
focus | fo |
format | f |
radius | r |
background | bg |
border | bo |
rotation | rt |
blur | bl |
named | n |
overlayImage | oi |
overlayX | ox |
overlayY | oy |
overlayFocus | ofo |
overlayHeight | oh |
overlayWidth | ow |
overlayText | ot |
overlayTextFontSize | ots |
overlayTextFontFamily | otf |
overlayTextColor | otc |
overlayAlpha | oa |
overlayTextTypography | ott |
overlayBackground | obg |
overlayImageTrim | oit |
progressive | pr |
lossless | lo |
trim | t |
metadata | md |
colorProfile | cp |
defaultImage | di |
dpr | dpr |
effectSharpen | e-sharpen |
effectUSM | e-usm |
effectContrast | e-contrast |
effectGray | e-grayscale |
original | orig |
<IKImage
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/gqyojxcwzxj/"
src="<full_image_url_from_db>"
v-bind:transformation="[{height:300,width:400}]" />
The above image will apply transformation of width = 90 and height = 180 on the image. Since some transformatinos are destructive you might want to control the order in which the transforms are applied.
Chained transforms make it easy to specify the order the transform are applied. example:
<IKImage
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/your_imagekit_id"
src="<full_image_url_from_db>"
v-bind:transformation="[{height:300,width:400},{rotation:90}]" />
In the above case, rotation will be performed first and resizing according to width and aspect ratio will be performed afterwards.
The SDK supports automatic support for LQIP for your images if you set lqip to true in the image component. example:
<IKImage
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/your_imagekit_id"
v-bind:lqip="{active:true,threshold:20}" />
active
tells the status for lqip. It can be either, true
or false
.
threshold
decides the quality of the placeholder image. It can be any numeric value, a low number means low quality, and a high number means high quality.
The component tries to keep it simple. It loads a lower quality image using the quality parameter to load a lower quality image, which is then replaced with the actual quality image later.
The SDK provides a simple Component to upload files to the ImageKit Media Library. It accepts fileName
parameter as a prop. The file parameter is provided as an input from the user.
Also, make sure that you have specified authenticationEndpoint
during SDK initialization. The SDK makes an HTTP GET request to this endpoint and expects a JSON response with three fields i.e. signature
, token
and expire
.
Learn how to implement authenticationEndpoint on your server.
An example of this server is provided in the samples folder of the SDK.
Sample Usage
<IKContext
publicKey="your_public_api_key"
urlEndpoint="https://ik.imagekit.io/your_imagekit_id"
authenticationEndpoint="http://www.yourserver.com/auth">
<IKUpload fileName="your_desired_filename"/>
</IKContext>
IKUpload
component accepts all the parameters supported by the ImageKit Upload API e.g. tags
, useUniqueFileName
, folder
etc.
You can also use onSuccess
and onError
callbacks to handle success and falure respectively, you can simply pass your custom functions to handle the response from API.
template: `<IKContext publicKey="${publicKey}" urlEndpoint="https://ik.imagekit.io/your_imagekit_id" authenticationEndpoint="http://www.yourserver.com/auth"><IKUpload fileName="your_desired_filename" :onError="onError" :onSuccess = "onSuccess" /></IKContext>`,
methods: {
onError(err) {
console.log(err);
}, onSuccess(res) {
console.log(res);
}},
The fastest way to get started is by running the demo application. You can run the code locally. The source code is in samples/sample-app. For the instructions in readme.md file within samples/sample-app folder.
For any feedback or to report any issues or general implementation support please reach out to support@imagekit.io
Released under the MIT license.
FAQs
[](https://imagekit.io)
The npm package imagekitio-vue receives a total of 239 weekly downloads. As such, imagekitio-vue popularity was classified as not popular.
We found that imagekitio-vue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.