New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@expo/dev-server

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/dev-server

Development servers for starting React Native projects


Version published
Weekly downloads
0
Maintainers
21
Weekly downloads
 
Created

What is @expo/dev-server?

@expo/dev-server is a development server for Expo projects. It provides a local server for serving your Expo app, enabling features like live reloading, error reporting, and debugging tools. This package is essential for a smooth development experience when working with Expo-based React Native applications.

What are @expo/dev-server's main functionalities?

Start Development Server

This feature allows you to start a development server for your Expo project. The server will serve your app and provide live reloading and other development tools.

const { startDevServerAsync } = require('@expo/dev-server');

async function startServer() {
  const server = await startDevServerAsync({
    projectRoot: __dirname,
    port: 19000
  });
  console.log(`Server is running on port ${server.port}`);
}

startServer();

Handle Errors

This feature demonstrates how to handle errors when starting the development server. It ensures that any issues encountered during server startup are properly logged.

const { startDevServerAsync } = require('@expo/dev-server');

async function startServer() {
  try {
    const server = await startDevServerAsync({
      projectRoot: __dirname,
      port: 19000
    });
    console.log(`Server is running on port ${server.port}`);
  } catch (error) {
    console.error('Failed to start server:', error);
  }
}

startServer();

Custom Middleware

This feature allows you to add custom middleware to the development server. In this example, a simple middleware logs the request URL for each incoming request.

const { startDevServerAsync } = require('@expo/dev-server');
const express = require('express');

async function startServer() {
  const app = express();
  app.use((req, res, next) => {
    console.log('Request URL:', req.url);
    next();
  });

  const server = await startDevServerAsync({
    projectRoot: __dirname,
    port: 19000,
    middleware: app
  });
  console.log(`Server is running on port ${server.port}`);
}

startServer();

Other packages similar to @expo/dev-server

FAQs

Package last updated on 15 Jun 2020

Did you know?

Socket

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.

Install

Related posts