npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@upst/iframe-funding-form

v2.0.0

Published

Upstart's `@upst/iframe-funding-form` SDK enables partners to embed Upstart's funding form on to their own sites via an iFrame. Partners will simply call this clientside SDK to open offer URLs.

Downloads

1,516

Readme

@upst/iframe-funding-form

Upstart's @upst/iframe-funding-form SDK enables partners to embed Upstart's funding form on to their own sites via an iFrame. Partners will simply call this clientside SDK to open offer URLs.

Setup

Choosing the Right Installation Method

npm (node package manager)

This method is recommended for modern web applications. The Upstart Embedded Browser SDK is packaged with the rest of your front-end JavaScript code. It has no impact on page load performance and can be dynamically imported when needed.

CDN async

This method is recommended for web applications with performance targets. The Upstart Embedded Browser SDK loads from a CDN asynchronously, ensuring the SDK download does not impact page load performance. However, the SDK may be slow to initialize if it's called early in the page's load.

CDN sync

This method is recommended if the Upstart Embedded Browser SDK needs to be initialized immediately. The SDK loads from a CDN synchronously, ensuring the SDK loads earlier in a page's lifecycle. This method may impact page load performance.

npm

Add @upst/iframe-funding-form to your package.json file, then initialize it with:

import UPST from '@upst/iframe-funding-form'

...
UPST.init({ offerUrl: '<upstart.com offer url>' })
...

<script>
(function(l,o,a,n,s) {
l=l[s]=l[s]||{q:[],onReady:function(c){l.q.push(c)}}
s=o.createElement(a);s.async=1;s.src=n
n=o.getElementsByTagName(a)[0];n.parentNode.insertBefore(s,n)
})(window,document,'script','https://www.unpkg.com/@upst/iframe-funding-form@<PACKAGE_VERSION>/dist/umd/bindle.min.js','UPST')
window.UPST.onReady(function() {
  ...

  window.UPST.init({ offerUrl: '<upstart.com offer url>' });

  ...
})
</script>

CDN Sync

<script
  src="https://www.unpkg.com/@upst/iframe-funding-form@<PACKAGE_VERSION>/dist/umd/bundle.min.js"
  type="text/javascript"
></script>
<script>
  ...

  window.UPST && window.UPST.init({ offerUrl: '<upstart.com offer url>' })

  ...
</script>

Usage

Above we have listed methods on how best to donwload and use our Javascript SDK. In terms of usage, it is important to note that upst.init({CONFIG}) should be called when the code is expected to open the iFrame. The most common use case is a button/link on your site that is expected to open the offer url. Instead of directly linking to the offer url, simply add a button event handler on the button, then when the button is clicked upst.init is called with the offer url.

import * as React from "react";
import UPST from "@upst/iframe-funding-form";

const UpstartIframeButton = (): React.ReactElement => {

  return (
    <Button
      onClick={(e) => {
        e.preventDefault();
        UPST.init({ offerUrl: iframeUrl });
      }}
    >
      Open Upstart iFrame
    </Button>
  );
};

export default UpstartIframeButton;

Alternatively, you might want to open the iFrame in other use cases, such as on page load. If that is the case, simply calling upst.init when your conditions are met with a valid offer URL will trigger the iframe to open.