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

@codexteam/deeplinker

v1.1.1

Published

Tiny script that helps you to use one link to open web pages or installed apps

Downloads

100

Readme

Deeplinker

This module helps you to create web-links for opening native applications directly if it is possible. Otherwise web page will be opened.

Install

You can install script via package managers or download it to your server.

NPM and Yarn

Install package

npm install @codexteam/deeplinker --save
yarn add @codexteam/deeplinker

Then require deeplinker module

const deeplinker = require('@codexteam/deeplinker');

Local script

Download dist/deeplinker.js file to your server and add it to your webpage.

<script src="dist/deeplinker.js" async></script>

Usage

Let's imagine that you want to create a link that opens some page in application, if it is installed. If target application is missing then link should open a web page as a normal link.

Check out example schemes below.

On click

Firstly you need to add the following params to deeplinker elements:

  • data-link or href with a usual link
  • data-app-link with a deep link (with custom protocol) to an application

Set up data-app-link param for links with href.

<a href="https://www.instagram.com/codex_team/" data-app-link="instagram://user?username=codex_team">
  Follow us on Instagram
</a>

Or set up data-link and data-app-link params for any other elements

<div data-link="https://t.me/codex_team" data-app-link="tg://resolve?domain=codex_team">
  Join our Telegram-channel
</div>

Then you need to add click listeners. There are two ways to do this.

Add listeners automatically

Add target class name to all deeplinker elements (deeplinker by default). Use deeplinker.init() function to add listeners automatically to all elements with target class name. event.preventDefault and deeplinker.click will be added as onclick function.

Run this function when page is loaded.

<body onload='deeplinker.init()'>
<div class="deeplinker" data-link="https://t.me/codex_team" data-app-link="tg://resolve?domain=codex_team">
  Join our Telegram-channel
</div>
Custom selector

You can call deeplinker.init() with string param to set up target selector. .deeplinker by default.

Example:

deeplinker.init('.my_deeplinker_element');

for

<div class="my_deeplinker_element" ...>
  Join our Telegram-channel
</div>

Set up onclick functions by yourself

Call deeplinker.click(element) function on click.

Set up click function on deeplinker elements.

<div onclick="deeplinker.click(this)"
     data-link="https://t.me/codex_team"
     data-app-link="tg://resolve?domain=codex_team">Join our Telegram-channel</div>

For link elements you also need to add event.preventDefault function:

<a href="https://www.instagram.com/codex_team/"
   onclick="event.preventDefault(); deeplinker.click(this)"
   data-app-link="instagram://user?username=codex_team">Follow us on Instagram</a>

Try to open app automatically

If you want to try to open app silently then call deeplinker.tryToOpenApp(deepLink).

Could be useful for redirection or invitation pages.

Doesn't work on mobile devices.

<body onload="deeplinker.tryToOpenApp('tg://user?username=codex_team')">

Schemes of popular apps

Telegram

tg://resolve?domain=[username]

Twitter

twitter://user?screen_name=[username]

Instagram

instagram://user?username=[username]

Facebook

fb://profile/[id]

VK

vk://vk.com/[id]

Issues and improvements

Feel free to ask a question or improve this project.

License

MIT