--- title: Web App Manifest slug: Web/Manifest tags: - App - Manifest - Reference - Web translation_of: Web/Manifest ---
O manifesto do aplicativo web fornece informações sobre uma aplicação (como nome, autor, icone, e descrição) em um arquivo de texto. O propósito do manifesto é instalar aplicações web na tela inicial de um aparelho, propiciando aos usuários um acesso mais rápido e uma experiência enriquecida.
Os manifestos dos aplicativos web fazem parte de um acervo de tecnologias de rede chamadas aplicativos web progressivos, sendo estes aplicativos web que podem ser instalados na tela inicial de um aparelho sem obrigar um usuário a passar por uma loja de aplicativos, dispondo também de outros superpoderes como estar disponíveis offline e apresentando aos usuários notificações push quando houverem mudanças de conteúdo do aplicativo.
Can PWA manifest contain comments?
It is a JSON-formatted file, with one exception: it is allowed to contain "//
"-style comments.
Manifesto de aplicativos web são implementados em suas páginas HTML usando uma etiqueta de link no cabeçalho do documento:
<link rel="manifest" href="/manifest.webmanifest">
Note: A extensão .webmanifest
está especificada na sessão de Media type registration da especificação, mas no geral os navegadores suportam manifestos em outras extensões apropriadas como .json
Note: Se o manifesto precisa de credenciais para ser buscado, você deve adicionar o atributo crossorigin
mesmo que o arquivo de manifesto esteja na mesma origem da página atual.
{ "name": "HackerWeb", "short_name": "HackerWeb", "start_url": ".", "display": "standalone", "background_color": "#fff", "description": "A simply readable Hacker News app.", "icons": [{ "src": "images/touch/homescreen48.png", "sizes": "48x48", "type": "image/png" }, { "src": "images/touch/homescreen72.png", "sizes": "72x72", "type": "image/png" }, { "src": "images/touch/homescreen96.png", "sizes": "96x96", "type": "image/png" }, { "src": "images/touch/homescreen144.png", "sizes": "144x144", "type": "image/png" }, { "src": "images/touch/homescreen168.png", "sizes": "168x168", "type": "image/png" }, { "src": "images/touch/homescreen192.png", "sizes": "192x192", "type": "image/png" }], "related_applications": [{ "platform": "web" }, { "platform": "play", "url": "https://play.google.com/store/apps/details?id=cheeaun.hackerweb" }] }
Manifest can contain the following keys:
{{ListSubpages("/en-US/docs/Web/Manifest")}}
Define a "cor de fundo" esperada para o website. Este valor repete o que já é disponível no CSS do site, mas pode ser usada por navegadores para desenhar cor de um atalho quando o manifesto estiver disponível antes que a folha de estilo (stylesheet) ter carregado. Isso cria uma transição suave entre a execução do aplicativo e o conteúdo do site.
"background_color": "red"
Note: O membro background_color
tem o único intuito de melhorar a experiência de usuário enquanto o site apontado está carregando, e não deve ser usado pelo agente de usuário como o {{cssxref("background-color", "background color")}} quando a folha de estilo do aplicativo web progressivo (PWA) estiver disponível.
Fornece uma descrição geral do que a aplicação faz.
"description": "O aplicativo que ajuda você a encontrar a melhor comida na cidade!"
Especifica a direção primário do texto para os membros name
, short_name
, e description
. Junto com o membro lang
, ajuda a mostrar corretamente idiomas escritos da direita para esquerda.
"dir": "rtl", "lang": "ar", "short_name": "أنا من التطبيق!"
Pode ter um dos valores a seguir:
ltr
(left-to-right)rtl
(right-to-left)auto
(hints to the browser to use the Unicode bidirectional algorithm to make a best guess about the text's direction.)Note: When the value is omitted, it defaults to auto
.
Define o modo de exibição preferido do desenvolvedor para a aplicação.
"display": "standalone"
Valid values are:
Member | Description |
---|---|
sizes |
A string containing space-separated image dimensions. |
src |
The path to the image file. If src is a relative URL, the base URL will be the URL of the manifest. |
type |
A hint as to the media type of the image. The purpose of this member is to allow a user agent to quickly ignore images of media types it does not support. |
purpose |
Defines the purpose of the image, for example that the image is intended to serve some special purpose in the context of the host OS (i.e., for better integration). The purpose member can have the following values:
|
Note: You can selectively apply CSS to your app based on the display mode, using the display-mode media feature. This can be used to provide a consistent user experience between launching a site from an URL and launching it from a desktop icon.
Specifies an array of image objects that can serve as application icons in various contexts. For example, they can be used to represent the web application amongst a list of other applications, or to integrate the web application with an OS's task switcher and/or system preferences.
"icons": [ { "src": "icon/lowres.webp", "sizes": "48x48", "type": "image/webp" }, { "src": "icon/lowres", "sizes": "48x48" }, { "src": "icon/hd_hi.ico", "sizes": "72x72 96x96 128x128 256x256" }, { "src": "icon/hd_hi.svg", "sizes": "72x72" } ]
Objetos de imagens podem conter os seguintes valores:
Member | Description |
---|---|
sizes |
A string containing space-separated image dimensions. |
src |
The path to the image file. |
type |
A hint as to the media type of the image.The purpose of this member is to allow a user agent to quickly ignore images of media types it does not support. |
Specifies the primary language for the values in the name
and short_name
members. This value is a string containing a single language tag.
"lang": "en-US"
Provides a human-readable name for the application as it is intended to be displayed to the user, for example among a list of other applications or as a label for an icon.
"name": "Google I/O 2015"
Defines the default orientation for all the web application's top level {{Glossary("Browsing context", "browsing contexts")}}.
"orientation": "portrait-primary"
Orientation pode ser um dos seguintes valores:
any
natural
landscape
landscape-primary
landscape-secondary
portrait
portrait-primary
portrait-secondary
Specifies a boolean value that hints for the user agent to indicate to the user that the specified related applications (see below) are available, and recommended over the web application. This should only be used if the related native apps really do offer something that the web application can't do.
"prefer_related_applications": false
Note: If omitted, the value defaults to false
.
Specifies an array of "application objects" representing native applications that are installable by, or accessible to, the underlying platform — for example a native Android application obtainable through the Google Play Store. Such applications are intended to be alternatives to the web application that provide similar or equivalent functionality — like the native app version of the web app.
"related_applications": [ { "platform": "play", "url": "https://play.google.com/store/apps/details?id=com.example.app1", "id": "com.example.app1" }, { "platform": "itunes", "url": "https://itunes.apple.com/app/example-app1/id123456789" }]
Application objects may contain the following values:
Member | Description |
---|---|
platform |
The platform on which the application can be found. |
url |
The URL at which the application can be found. |
id |
The ID used to represent the application on the specified platform. |
Defines the navigation scope of this web application's application context. This basically restricts what web pages can be viewed while the manifest is applied. If the user navigates the application outside the scope, it returns to being a normal web page.
"scope": "/myapp/"
Provides a short human-readable name for the application. This is intended for use where there is insufficient space to display the full name of the web application.
"short_name": "I/O 2015"
Specifies the URL that loads when a user launches the application from a device.
"start_url": "./?utm_source=web_app_manifest"
Defines the default theme color for an application. This sometimes affects how the application is displayed by the OS (e.g., on Android's task switcher, the theme color surrounds the application).
"theme_color": "aliceblue"
In Chrome 47 and later, a splash screen is displayed for a web application launched from a home screen. This splashscreen is auto-generated using properties in the web app manifest, specifically: name
, background_color
, and the icon in the icons
array that is closest to 128dpi for the device.
Manifests should be served using the application/manifest+json
MIME type. However, it is optional to do so.
Especificação | Status | Comentário |
---|---|---|
{{SpecName('Manifest')}} | {{Spec2('Manifest')}} | Definição inicial. |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatChrome(39.0)}} | {{CompatUnknown}} | {{CompatUnknown}} | 32.0 | {{CompatUnknown}} | {{CompatChrome(39.0)}} |
background_color |
{{CompatNo}} | {{CompatChrome(46.0)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatChrome(46.0)}} [1] |
theme_color |
{{CompatNo}} | {{CompatChrome(46.0)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatChrome(46.0)}} [1] |
icons , name , short_name , and theme_color used for Add to home screen feature. |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(53)}}[2] | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
display |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(47)}}[3] | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(39.0)}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
[1] Does not support lang
or scope
.
[2] The icons
, name
, short_name
, and theme_color
fields of the Web App Manifest (if present) can now be as the source of the homescreen/apps window icons, apps window title, homescreen icon title, and apps window color (respectively) for "Add to home screen" (Firefox Mobile only; see {{bug("1234558")}}). Experimental support for this feature is available behind the boolean flag manifest.install.enabled
in about:config
.
[3] Only the browser
value of display
was supported in 47. minimal-ui
, standalone
, and fullscreen
were added in Firefox 57.