![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
device-redirect
Advanced tools
Redirect your users to device-specific apps and interstitial pages
Redirect your users to device-specific apps and interstitial pages.
device-redirect
is a JavaScript module that provides a simple API to redirect your users to device-specific app URLs, with fallbacks to interstitial or mobile friendly web pages.
We use device-redirect at Help Scout to let our iOS users know they can get the full mobile experience with our new iPhone App.
npm install device-redirect --save-dev
bower install https://npmcdn.com/device-redirect/bower.zip --save-dev
https://npmcdn.com/device-redirect/dist/device-redirect.js
https://npmcdn.com/device-redirect/dist/device-redirect.min.js
<script src="device-redirect.min.js"></script>
<script>
var dr = new DeviceRedirect(window.navigator.userAgent, { ...options });
</script>
define(['./path/to/device-redirect'], function(DeviceRedirect) {
var dr = new DeviceRedirect(window.navigator.userAgent, { ...options });
});
// ES6
import DeviceRedirect from 'device-redirect'
// ES5
var DeviceRedirect = require('device-redirect');
var dr = new DeviceRedirect(window.navigator.userAgent, { ...options });
constructor(userAgent : string, <options : object>)
Creates a new DeviceRedirect instance for the specified user agent string. Example:
var dr = new DeviceRedirect(window.navigator.userAgent, {
rules: { ... }
});
openApp()
Will try to redirect to the given appUrl
for the matching device. If if fails to do that (this usually means the user doesn't have the native app installed in his device), it will redirect to the given redirectUrl
for the matching device. Example:
var dr = new DeviceRedirect(window.navigator.userAgent, {
rules: {
'iOS': {
appUrl: 'my-iphone-app://article/1234',
redirectUrl: 'https://itunes.apple.com'
}
}
});
dr.openApp();
// On an iOS device, will try to open 'my-iphone-app://article/1234' on a native app.
// If it fails, it'll redirect to 'https://itunes.apple.com'.
rules : object
A map object describing supported devices and URLs to redirect. Example:
var dr = new DeviceRedirect(window.navigator.userAgent, {
rules: {
'iOS': {
appUrl: 'my-iphone-app://article/1234',
redirectUrl: 'https://itunes.apple.com'
},
'AndroidOS': {
appUrl: 'my-android-app://article/1234',
redirectUrl: 'https://play.google.com'
}
}
});
Keys are used to match a user agent, OS, phone or tablet. This is the list of possible keys:
// General Keys:
Bot, MobileBot, DesktopMode, TV, WebKit, Console, Watch
// User Agent Keys:
Chrome, Dolfin, Opera, Skyfire, IE, Firefox, Bolt, TeaShark, Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser
// OS Keys:
AndroidOS, BlackBerryOS, PalmOS, SymbianOS, WindowsMobileOS, WindowsPhoneOS, iOS, MeeGoOS, MaemoOS, JavaOS, webOS, badaOS, BREWOS
// Phone Keys:
iPhone, BlackBerry, HTC, Nexus, Dell, Motorola, Samsung, LG, Sony, Asus, Micromax, Palm, Vertu, Pantech, Fly, Wiko, iMobile, SimValley, Wolfgang, Alcatel, Nintendo, Amoi, INQ, GenericPhone
// Tablet Keys:
iPad, NexusTablet, SamsungTablet, Kindle, SurfaceTablet, HPTablet, AsusTablet, BlackBerryTablet, HTCtablet, MotorolaTablet, NookTablet, AcerTablet, ToshibaTablet, LGTablet, FujitsuTablet, PrestigioTablet, LenovoTablet, DellTablet, YarvikTablet, MedionTablet, ArnovaTablet, IntensoTablet, IRUTablet, MegafonTablet, EbodaTablet, AllViewTablet, ArchosTablet, AinolTablet, SonyTablet, PhilipsTablet, CubeTablet, CobyTablet, MIDTablet, MSITablet, SMiTTablet, RockChipTablet, FlyTablet, bqTablet, HuaweiTablet, NecTablet, PantechTablet, BronchoTablet, VersusTablet, ZyncTablet, PositivoTablet, NabiTablet, KoboTablet, DanewTablet, TexetTablet, PlaystationTablet, TrekstorTablet, PyleAudioTablet, AdvanTablet, DanyTechTablet, GalapadTablet, MicromaxTablet, KarbonnTablet, AllFineTablet, PROSCANTablet, YONESTablet, ChangJiaTablet, GUTablet, PointOfViewTablet, OvermaxTablet, HCLTablet, DPSTablet, VistureTablet, CrestaTablet, MediatekTablet, ConcordeTablet, GoCleverTablet, ModecomTablet, VoninoTablet, ECSTablet, StorexTablet, VodafoneTablet, EssentielBTablet, RossMoorTablet, iMobileTablet, TolinoTablet, AudioSonicTablet, AMPETablet, SkkTablet, TecnoTablet, JXDTablet, iJoyTablet, FX2Tablet, XoroTablet, ViewsonicTablet, OdysTablet, CaptivaTablet, IconbitTablet, TeclastTablet, OndaTablet, JaytechTablet, BlaupunktTablet, DigmaTablet, EvolioTablet, LavaTablet, AocTablet, CelkonTablet, WolderTablet, MiTablet, NibiruTablet, NexoTablet, LeaderTablet, UbislateTablet, PocketBookTablet, Hudl, TelstraTablet, GenericTablet
shouldRedirect : function
The default implementation of shouldRedirect
always returns true
. Overwrite this method to control if it should redirect to the URL specified in redirectUrl
for the matching device. Example:
var dr = new DeviceRedirect(window.navigator.userAgent, {
rules: { ... },
shouldRedirect: function() {
if(localStorage.getItem('userAlreadyOptedOutOfThisFeature')) {
return false;
}
return true;
}
});
npm install
npm run build
npm test
MIT
FAQs
Redirect your users to device-specific apps and interstitial pages
The npm package device-redirect receives a total of 5 weekly downloads. As such, device-redirect popularity was classified as not popular.
We found that device-redirect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.