Docs
Methods
MethodsSign Up | Fire Snippets Docs

Sign Up

Handles user sign-up by attaching an onclick event listener to a specified button.

signUp(snippetId)

Description

Handles user sign-up by attaching an onclick event listener to a specified button. When the button is clicked, it creates a new user using Firebase Auth and saves additional user data to Firestore.

Method Signature

signUp(snippetId)

Parameters

  • snippetId: (string) The ID of the sign-up snippet configuration.

Returns

  • Promise: Resolves with a userCredential object upon successful sign-up, or rejects with an error.

Usage Example

// Initialize FireSnippets
const fireSnippets = new FireSnippets('your-api-key');
 
// Call the signUp method
fireSnippets.signUp('your-signup-snippet-id')
  .then(userCredential => {
    // User signed up successfully
    console.log('User signed up:', userCredential);
  })
  .catch(error => {
    // Handle sign-up errors
    console.error('Sign-up error:', error);
  });

HTML Elements Required

Ensure your HTML includes the following elements with IDs matching those specified in your snippet configuration:

<input type="email" id="email-input" placeholder="Email">
<input type="password" id="password-input" placeholder="Password">
<!-- Additional fields as per fieldMappings -->
<input type="text" id="first-name-input" placeholder="First Name">
<input type="text" id="last-name-input" placeholder="Last Name">
<button id="signup-button">Sign Up</button>

Was this helpful?
Docs
Copyright © Fire Snippets. All rights reserved.