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 🙏

© 2026 – Pkg Stats / Ryan Hefner

expo-nslookup

v0.2.1

Published

My new module

Downloads

16

Readme

expo-nslookup

npm version License: MIT

A native DNS lookup module for Expo and React Native applications. Perform fast, native DNS lookups to check domain availability and DNS resolution with configurable timeout options.

Features

  • 🚀 Native Performance: Leverages platform-native DNS resolution (iOS and Android)
  • Fast Lookups: Optimized for speed with configurable timeout options
  • 🎯 Simple API: Easy-to-use Promise-based interface
  • 📱 Cross-Platform: Works seamlessly on iOS and Android
  • 🔧 TypeScript Support: Fully typed for better development experience
  • ⏱️ Configurable Timeout: Set custom timeout values for DNS queries

Installation

Prerequisites

Ensure you have installed and configured the expo package in your project.

Install the package

npm install expo-nslookup

or with yarn:

yarn add expo-nslookup

Platform-Specific Setup

iOS

Run the following command after installing the package:

npx pod-install

Android

No additional configuration required. The module will be automatically linked.

Usage

Basic Example

import ExpoNslookupModule from "expo-nslookup";

// DNS lookup with default timeout (1 second)
const checkDomain = async () => {
  try {
    const result = await ExpoNslookupModule.lookup("example.com");
    console.log("Success:", result.success);
    console.log("Domain:", result.domain);
    console.log("Has Addresses:", result.hasAddresses);
  } catch (error) {
    console.error("Lookup failed:", error);
  }
};

With Custom Timeout

import ExpoNslookupModule from "expo-nslookup";

// Lookup with custom timeout
const lookupWithTimeout = async () => {
  try {
    const result = await ExpoNslookupModule.lookup("example.com", {
      timeout: 5.0, // 5 seconds timeout
    });

    if (result.success && result.hasAddresses) {
      console.log(`✅ ${result.domain} resolves successfully`);
    } else {
      console.log(`❌ ${result.domain} does not resolve`);
    }
  } catch (error) {
    console.error("Lookup failed:", error);
  }
};

Complete Example

import ExpoNslookupModule from "expo-nslookup";
import { Button, Text, TextInput, View } from "react-native";
import { useState } from "react";

export default function App() {
  const [domain, setDomain] = useState("google.com");
  const [result, setResult] = useState<string | null>(null);
  const [loading, setLoading] = useState(false);

  const performLookup = async () => {
    try {
      setLoading(true);
      const lookupResult = await ExpoNslookupModule.lookup(domain.trim(), {
        timeout: 3.0,
      });

      if (lookupResult.success && lookupResult.hasAddresses) {
        setResult("✅ Domain resolves successfully");
      } else {
        setResult("❌ Domain not found");
      }
    } catch (error: any) {
      setResult(`⚠️ Error: ${error.message}`);
    } finally {
      setLoading(false);
    }
  };

  return (
    <View>
      <TextInput
        value={domain}
        onChangeText={setDomain}
        placeholder="Enter domain name"
        autoCapitalize="none"
        autoCorrect={false}
      />
      <Button
        title={loading ? "Looking up..." : "Check Domain"}
        onPress={performLookup}
        disabled={loading}
      />
      {result && <Text>{result}</Text>}
    </View>
  );
}

API Reference

ExpoNslookupModule.lookup(domain: string, options?: DNSLookupOptions): Promise<DNSLookupResult>

Performs a DNS lookup for the specified domain with optional configuration.

Parameters:

  • domain (string): The domain name to lookup (e.g., "example.com")
  • options (optional): Configuration options
    • timeout (number): Timeout in seconds (default: 1.0)

Returns:

  • Promise<DNSLookupResult>: An object containing:
    • success (boolean): Whether the lookup was successful
    • domain (string): The queried domain
    • hasAddresses (boolean): Whether DNS addresses were found

Example:

// Without options (uses default 1 second timeout)
const result = await ExpoNslookupModule.lookup("github.com");

// With custom timeout
const result = await ExpoNslookupModule.lookup("example.com", {
  timeout: 5.0,
});

TypeScript Types

interface DNSLookupResult {
  success: boolean;
  domain: string;
  hasAddresses: boolean;
}

interface DNSLookupOptions {
  timeout?: number; // Timeout in seconds (default: 1.0)
}

Use Cases

  • Network Diagnostics: Check if a domain is reachable before making requests
  • Domain Validation: Verify domain existence in forms and inputs
  • Connectivity Testing: Test DNS resolution as part of connectivity checks
  • Custom DNS Monitoring: Build monitoring tools for domain availability
  • Offline Detection: Determine if DNS resolution is working

Troubleshooting

iOS Issues

If you encounter build issues on iOS:

  1. Run npx pod-install again
  2. Clean the build folder in Xcode
  3. Rebuild the project

Android Issues

If you encounter build issues on Android:

  1. Clean the build: cd android && ./gradlew clean
  2. Rebuild the project

Requirements

  • Expo SDK 53 or higher
  • React Native 0.79.1 or higher
  • iOS 13.0 or higher
  • Android API level 21 or higher

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Bilal Serwan

Links


Made with ❤️ by Bilal Serwan