Service for retrieving form schemas and submitting form data.
Accessible via lynkow.forms. Forms are dynamic, CMS-managed forms with
configurable fields, validation rules, and spam protection. The service
automatically handles honeypot anti-spam fields on submissions. Form schemas
are cached for 10 minutes (MEDIUM TTL).
Access via: lynkow.forms
Methods
3 methods
clearCache
clearCache(): voidInvalidates all cached form schema responses. Call this if you know a form definition has changed and want to fetch the latest schema.
Returns: void
getBySlug
getBySlug(slug: string): Promise<Form>Retrieves a form definition by its slug, including the field schema, validation rules, settings (submit label, success message), and spam protection configuration (honeypot/reCAPTCHA). Cached for 10 minutes.
Parameter | Type | Description |
|---|---|---|
|
| The unique slug of the form (e.g. |
Returns: Promise<Form>
const form = await lynkow.forms.getBySlug('contact')
// Iterate fields to render the form dynamically
form.schema.forEach(field => {
console.log(field.name, field.type, field.required)
})
// Check spam protection config
if (form.recaptchaEnabled) {
// Render reCAPTCHA widget using form.recaptchaSiteKey
}submit
submit(slug: string, data: FormSubmitData, options?: SubmitOptions & BaseRequestOptions): Promise<FormSubmitResponse>Submits form data to the API. Anti-spam honeypot fields (_hp, _ts) are
injected automatically by the SDK -- you do not need to add them yourself.
If the form has reCAPTCHA enabled, pass the token via options.recaptchaToken.
Parameter | Type | Description |
|---|---|---|
|
| The slug of the form to submit to (e.g. |
|
| Key-value pairs matching the form's field names.<br> Values can be |
|
| Optional submission options:<br> - |
Returns: Promise<FormSubmitResponse>
const result = await lynkow.forms.submit('contact', {
name: 'John Doe',
email: '[email protected]',
message: 'Hello!'
})
if (result.status === 'pending') {
// Show "check your email" confirmation
} else {
// Show success message
console.log(result.message)
}