Key features • Installation • Pre-requisites • Creating deep links • Related
- Convert links into deep links
- Pass a user agent to correctly determine which link to provide
- Automatically fallback to default URL if a type can't be determined
- Support for many platforms
- TikTok
- SnapChat
- YouTube
- ...and more coming soon!
- 100% free and open-source
npm i nc-deeplink
yarn add nc-deeplink
# install dependencies
npm install
# (optional) install typescript globally
npm install typescript -g
# build the library (automatically copies important files and compiles typescript)
npm run build
DeepLink uses user agents to determine a valid destination for a link. You can grab this user agent any way you need to.
import {DeepLinker} from "nc-deeplink";
// or
const Index = require("nc-deeplink");
import {DeepLinker} from "nc-deeplink";
let userAgent = navigator.userAgent;
let deepLink = DeepLinker.parseDeepLink(url, userAgent);
console.log(deepLink);
import {DeepLinker} from "nc-deeplink";
let deepLink = DeepLinker.convertToDeepLink(url, "Android");
console.log(deepLink);
deepLink = DeepLinker.convertToDeepLink(url, "iOS");
console.log(deepLink);
import {DeepLinker} from "nc-deeplink";
let userAgent = navigator.userAgent;
let isMobile = DeepLinker.isMobile(url, userAgent);
console.log(isMobile)
Link Apps are how DeepLink figures out how to convert a link into a deep link.
DeepLink provides a number of mappings by default, but if you wish to add more, you may do so.
import {DeepLinkGenerator} from "nc-deeplink";
import {LinkApp} from "nc-deeplink";
class RedditLinkApp extends LinkApp {
constructor(url?: string) {
super(url, "reddit.com", undefined, "com.reddit.frontpage");
}
getAndroidLink(): string {
return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`;
}
getiOSLink(): string {
return this.originalUrl;
}
}
DeepLinkGenerator.mappings.push(new RedditLinkApp());
Singlelink is Neutron Creative product, created and hosted free of charge in the mission of open-source. To learn more about our mission, visit neutroncreative.com
- Capture, Simplified screenshot API (https://capture.neutron.so)
- Sponsorware, Sell software with Github Sponsors (https://sponsorware.neutron.so)
- Cowlytics, Real-time Stripe analytics & forcesting for SaaS (https://www.cowlytics.co)
- Neutron, Faster websites in one-click (https://neutroncreative.com)