Link Creation
Generate smart links programmatically in your web app
Creating a link
Use createLink to generate a smart link:
grovs.createLink(
'Check out this product', // title
'Limited time offer', // subtitle
'https://example.com/image.jpg', // imageURL
{ // data
productId: '12345',
screen: 'product_detail',
},
(response) => {
console.log('Link created:', response);
},
(error) => {
console.error('Error:', error);
}
);Parameters
| Parameter | Type | Description |
|---|---|---|
title | string | Link preview title |
subtitle | string | Link preview subtitle |
imageURL | string | Link preview image URL |
data | object | Custom payload delivered when the link is opened |
success | function | Callback on successful link creation |
error | function | Callback on error |
Full example
import Grovs from 'grovs';
const grovs = new Grovs('your-api-key', (data) => {
console.log('Link data:', data);
});
grovs.start();
// Wait for authentication, then create a link
if (grovs.authenticated()) {
grovs.createLink(
'Share this page',
'Check out what I found',
'https://example.com/og-image.jpg',
{ page: '/products/12345', source: 'share' },
(response) => console.log('Created:', response),
(error) => console.error('Failed:', error)
);
}