Skip to content

Svelte Surefeedback

A Svelte wrapper component for SureFeedback (ProjectHuddle) that provides seamless integration with your Svelte applications.

Terminal window
npm install svelte-surefeedback
  • Easy integration with Svelte applications
  • Type-safe with full TypeScript support
  • Automatic script loading and cleanup
  • Token persistence management
  • Debug mode for troubleshooting
  • Configurable timeout handling
  • Event callbacks for load and error states

Basic usage:

<script>
import { SureFeedback } from 'svelte-surefeedback';
</script>
<SureFeedback
url="//feedback.mindhyv.com/?p=YOUR_PROJECT_ID&ph_apikey=YOUR_API_KEY"
/>

Advanced usage with all options:

<script>
import { SureFeedback } from 'svelte-surefeedback';
function handleError(error) {
console.error('SureFeedback error:', error);
}
function handleLoaded() {
console.log('SureFeedback loaded successfully');
}
</script>
<SureFeedback
url="//feedback.mindhyv.com/?p=YOUR_PROJECT_ID&ph_apikey=YOUR_API_KEY"
enabled={true}
debug={true}
timeout={15000}
persistToken={true}
tokenKey="ph_access_token"
onError={handleError}
onLoaded={handleLoaded}
/>
OptionTypeDefaultDescription
urlstringRequiredThe SureFeedback URL with your project ID and API key
enabledbooleantrueEnable/disable the feedback widget
debugbooleanfalseEnable debug mode for detailed logging
timeoutnumber10000Script loading timeout in milliseconds
persistTokenbooleantrueWhether to persist the access token in localStorage
tokenKeystring'ph_access_token'Custom key for storing the token
onError(error: string) => voidundefinedCallback function for error handling
onLoaded() => voidundefinedCallback function when script loads successfully

The component includes built-in error handling for:

  • Invalid URLs
  • Missing required parameters
  • Script loading failures
  • Timeout issues
  • LocalStorage access problems

Errors are displayed in a clear message and can be caught using the onError callback.

When debug mode is enabled, the component will log detailed information about:

  • Script loading process
  • Token management
  • Error states
  • Cleanup operations

Enable debug mode during development:

<SureFeedback
url="your-url"
debug={true}
/>

The package includes full TypeScript definitions. You can import types:

import type { SureFeedbackProps } from 'svelte-surefeedback';
  • Svelte 5.x
  • SureFeedback/ProjectHuddle account and API credentials

MIT

Contributions are welcome! Please feel free to submit a Pull Request.