How to store URLs in your App Clip Codes
December 14, 2020
An App Clip is a small part of your app which provides specific information that best suits a given task or situation. An App Clip Code activates your App Clip, helping people access relevant information wherever they happen to be — whether they’re picking up takeout from a restaurant, reading an article online, or passing by an advertisement in their neighborhood.
To make your App Clip Code, you’ll need to create a URL that directly connects to your content. And because codes can only hold a finite number of characters, you’ll need to design your URL efficiently. Here’s what you need to know to make and store a URL for your App Clip Code.
How App Clip Code URLs work
App Clip Codes support URLs in the following format:
https://[host][/<optional path>][?<optional query>][#<optional fragment>]
URLs must use the
https scheme, all lowercase.
The host segment can only contain lowercase ASCII characters ‘a’ to ‘z’, ‘.’ and ‘-’ characters. Host is the only part of the authority component of the URL that is supported.
The rest of the URL can have zero or more path components, zero or more query components, and, optionally, a fragment component. These components can contain the following ASCII characters:
How to store URLs efficiently in your App Clip Codes
When creating a URL, you can optimize its string length to fit within the App Clip Code’s character limit in a number of different ways.
Make it short and sweet Above all, aim for your URLs to be as short and concise as possible. URLs with fewer characters, path, and query components have a better chance to fit into an App Clip Code.
We recommend using a short host name with as few subdomains as possible, as well as removing the www subdomain whenever possible. You’ll also want to omit a trailing ‘/’ character from the end of the URL if possible. For instance,
https://www.example.com/ can be changed to
If you do plan to use a subdomain, consider using
appclip to define App Clip-specific URLs for App Clip Codes. This special subdomain is compressed efficiently and it allows URLs to have short path and query components by eliminating the possibility of a conflict with an unrelated functionality of your website.
While adding this subdomain is optional, if you do opt to use it, it must appear as the first subdomain of the URL’s host, like so:
Optimize for compression Consider using the minimum number of characters needed to uniquely identify a resource in your URLs, as long UUIDs will lower the effectiveness of the compression.
In addition, replace long query string argument names and values with short names and values to aid in compression. For example, you can turn argument names into shorter names and values into an enum, like so:
https://example.com/?status=view could be restructured as
Using decimal numbers as query parameter values may also lead to better compression of the URL.
Choose your words carefully
App Clip Codes offer more effective URL encoding for certain words in the URL path component, like
visit, and more. Consider using these whenever possible to improve your encoding and compression. You can view the full list of words within Apple’s documentation.
In addition, a URL that contains zero or one path component from the list of special words and contains zero or more query components with ordered argument names p, p1, p2, and the like has a higher likelihood of fitting in an App Clip Code. Some examples: