Access the user's current store location for location-based services and regional content in your application using the Despia SDK from: https://www.npmjs.com/package/despia-native
First, install the package: npm install despia-native
Then import it: import despia from 'despia-native'
-
Import the Despia SDK in your component
-
Access the store location using
despia.storeLocation
-
Display the store location in your UI
-
Use the location data for regional content and localized features
This feature requires native capabilities which will be fully provided by the "despia-native" npm package, no additional native libraries are needed!
Please follow the installation instructions for the "despia-native" npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
How it works: The Despia Store Location SDK enables your application to access the user's current store location to provide location-based services, regional content, and localized experiences. This lightweight solution runs entirely client-side through despia.storeLocation
, requiring no server-side setup or configuration.
Installation
Install the Despia package from NPM:
npm install despia-native
Usage
1. Import the SDK
import despia from 'despia-native';
2. Get Store Location
Access the store location from the despia.storeLocation
variable:
// Simple example - show store location and checkout button
const storeLocation = despia.storeLocation;
// Display in UI
<div>
<p>Your Store Location: {storeLocation}</p>
{storeLocation === 'USA' && (
<button onClick={handleWebPayment}>
Checkout with Web Payment
</button>
)}
</div>
// Handle web payment for US users
const handleWebPayment = () => {
// Process web payment
console.log('Processing US web payment');
};
Backend Integration
This is merely an illustration; your implementation may differ.
// /api/store-location endpoint
export default async function handler(req, res) {
const { userId, storeLocation, timestamp } = req.body;
try {
// Store the location data in your database
await db.collection('user_locations').doc(userId).set({
userId,
storeLocation,
lastChecked: timestamp,
createdAt: timestamp
}, { merge: true });
res.status(200).json({ success: true });
} catch (error) {
res.status(500).json({ error: 'Failed to sync store location' });
}
}
Resources
- NPM Package
-
View full NPM documentation for additional configuration options
Lovable Integration
This SDK is optimized for Lovable's prompt-based AI builder, enabling quick integration of native file sharing capabilities into your generated apps.
For additional support or questions, please contact our support team at support@despia.com