Getting Started with Expo Web

evanbacon

Evan Bacon

Posted on January 29, 2020

Getting Started with Expo Web

πŸ‘‰ This guide is for beginner React devs with no knowledge of Expo, or building mobile apps.

Expo lets you build and deploy real iOS, Android, and Web apps with React and JavaScript. Expo websites are performant and highly customizable; meaning you can use them with any of your existing React tools like Next.js, Gatsby, Preact, Electron, etc...

This guide will quickly show you the basics for creating a website and deploying it to the web in minutes! For more on mobile apps check out the Expo docs.

You'll Learn how to:


Getting Started

Install the Expo CLI and make a new universal project (Web, iOS, Android):

πŸ’‘ Absolute beginners with no coding experience should visit snack.expo.io to get started in the browser without using the terminal.



$ npm install -g expo-cli


Enter fullscreen mode Exit fullscreen mode

Create a new Expo project:

πŸ’‘ Learn more about expo init



$ expo init myProject 


Enter fullscreen mode Exit fullscreen mode

Now enter the project and start it:



$ cd myProject

$ expo start --web


Enter fullscreen mode Exit fullscreen mode

Your browser will automatically open to the website and you'll see this:

Alt Text

Building

Creating a production build is simple:

πŸ’‘ Expo Web builds live in the web-build folder.



$ expo build:web


Enter fullscreen mode Exit fullscreen mode

You can deploy the website using any hosting service. For this example we'll use Netlify:



$ npx netlify deploy --dir web-build


Enter fullscreen mode Exit fullscreen mode

And that's all! You just created and deployed your first universal Expo website!! See some examples and learn more in the Expo Documentation.

πŸ€” How Expo Web Works

Every screen in an Expo app is a React Component, but instead of using <div/>, <p/>, <img/> - Expo uses <View />, <Text />, <Image />, <ScrollView />, etc...

The first component in your app is whatever JSX you export from App.js:



import React from 'react';
import { Text } from 'react-native';

function App() {
  return <Text>Expo Everywhere!</Text>
}

export default App;


Enter fullscreen mode Exit fullscreen mode

πŸƒπŸ»β€β™‚οΈ Running Everywhere

  • 🌐 Try Expo Web in the browser with: ```sh

$ expo start --web

or faster in web-only mode

$ expo start:web

- πŸ’» Run in the **simulator** with:
```sh


$ expo start --ios

# or Android

$ expo start --android


Enter fullscreen mode Exit fullscreen mode
  • πŸ“± You can also open this on your phone with the Expo client!

πŸ•΅οΈβ€β™€οΈ Learn More

πŸ‘‹ Thanks for Reading

That's all for now. Keep up with the latest Expo Web news by following πŸ‘‡

πŸ’– πŸ’ͺ πŸ™… 🚩
evanbacon
Evan Bacon

Posted on January 29, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related