File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
packages/formspree-ajax/src Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 11import {
2+ createClient ,
23 getDefaultClient ,
34 isSubmissionError ,
45 appendExtraData ,
@@ -421,7 +422,9 @@ export const initForm = <T extends FieldValues = FieldValues>(
421422 const form = getFormElement ( config . formElement ) ;
422423 const formKey = config . formId ;
423424 const endpoint = config . origin ?? DEFAULT_ENDPOINT ;
424- const client : Client = getDefaultClient ( ) ;
425+ const client : Client = config . projectId
426+ ? createClient ( { project : config . projectId } )
427+ : getDefaultClient ( ) ;
425428
426429 const context : FormContext < T > = {
427430 form,
Original file line number Diff line number Diff line change @@ -116,7 +116,11 @@ export type MessageType = 'success' | 'error';
116116 * @template T - The type of field values for the form, defaults to FieldValues.
117117 */
118118export interface FormConfig < T extends FieldValues = FieldValues > {
119- // TODO: add a project id
119+ /**
120+ * The Formspree project ID. When provided, submissions are sent to
121+ * `/p/{projectId}/f/{formId}` instead of `/f/{formId}`.
122+ */
123+ projectId ?: string ;
120124
121125 /**
122126 * The form element to attach to, either as an HTMLFormElement or a CSS selector string.
You can’t perform that action at this time.
0 commit comments