> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Redirecting Mobile Visitors

## Article: Redirecting Mobile Visitors

## Article Link: https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/frontend-code/mobile/redirecting-mobile-visitors.md

## Article Content:

# Velo Tutorial: Redirecting Mobile Visitors

<div style="background: #D9F4F4; border: 1px solid #B3E9E8; border-radius: 6px; padding: 7px 17px 7px 17px; width: max-content; margin-top: 5px; margin-bottom: 5px;">Visit the <a style="text-decoration: color: #3197EF;" href="fallback::https://www.wix.com/velo" target="_blank">Velo by Wix website</a> to onboard and continue learning.</div>

You can use Velo to redirect visitors to mobile-friendly pages in your site.

The basic steps to redirect to mobile pages are:

1.  Use code to check if your site is being viewed on a mobile device or a desktop device
2.  If your site is being viewed on a mobile device, use code to redirect to another page

This tutorial has 2 parts:

*   Instructions on how to get set up, including code you can copy and paste onto your page
*   An explanation of what each line of code does

### Instructions

1.  Go to your site's home page.
2.  Copy the code below and paste it in your page code.
3.  Make sure to substitute your mobile home page URL in line 9 where it says 'http://www.myMobileHome.com.'
4.  Publish the page to see the redirect in action. (Previewing isn't enough.)

```javascript
import wixLocationFrontend from 'wix-location-frontend';
import wixWindowFrontend from 'wix-window-frontend';

$w.onReady(function () {

 setTimeout(function () {

  if(wixWindowFrontend.formFactor === "Mobile"){
     wixLocationFrontend.to('http://www.myMobileHome.com');        
   }
 }, 7500);

});
```

### Understanding the Code

The code checks the kind of device. If mobile, the code redirects the visitor to a mobile-friendly home page.

Import statements on lines 2 and 3 bring in the APIs we need:

*   [`wixWindowFrontend.formFactor`](https://www.wix.com/velo/reference/wix-window.html#formFactor) checks the device type.
*   [`wixLocationFrontend.to`](https://www.wix.com/velo/reference/wix-location.html#to) redirects the visitor to the mobile page's URL.

```javascript
// Import statements for the Wix Location Frontend and Window APIs
import wixLocationFrontend from 'wix-location-frontend';
import wixWindowFrontend from 'wix-window-frontend';
```

The redirect occurs after a time delay. This gives the visitor time to see notices on the page you are redirecting from. Line 4 contains the setTimeout function that creates this delay.

```javascript
$w.onReady(function () {

// Adds a time delay so the visitor anticipates the redirect    
 setTimeout(function () {

...
...
...

 // The timeout value is 7500 nanoseconds
 }, 7500);

});
```

With an **if** statement on line 10, we check the type of device using `wixWindowFrontend.formFactor`.

```javascript
import wixLocationFrontend from 'wix-location-frontend';
import wixWindowFrontend from 'wix-window-frontend';

$w.onReady(function () {

// Adds a time delay so the visitor anticipates the redirect    
 setTimeout(function () {

  // Checks what kind of device
  if(wixWindowFrontend.formFactor === "Mobile"){
      
     // If mobile, we redirect to a mobile-friendly page
     wixLocationFrontend.to('http://www.myMobileHome.com');        
   }

 // The timeout value is 7500 milliseconds
 }, 7500);

});
```

On line 13, we use `wixLocationFrontend.to` to perform the redirect.

### API List

The following APIs are used in the code in this article. To learn more, see the [API Reference](https://www.wix.com/velo/reference/).

*   [wix-window-frontend](https://www.wix.com/velo/reference/wix-window.html)
*   [wix-location-frontend](https://www.wix.com/velo/reference/wix-location.html)