Stay organized with collections Save and categorize content based on your preferences.
If you build a user interface for a script, you can publish the script as a web app. For example, a script that lets users schedule appointments with members of a support team would best be presented as a web app so that users can access it directly from their browsers.
Both standalone scripts and scripts bound to Google Workspace applications can be turned into web apps, so long as they meet the requirements below.
Requirements for web appsA script can be published as a web app if it meets these requirements:
doGet(e)
or doPost(e)
function.HtmlOutput
object or a Content service TextOutput
object.When a user visits an app or a program sends the app an HTTP GET
request, Apps Script runs the function doGet(e)
. When a program sends the app an HTTP POST
request, Apps Script runs doPost(e)
instead. In both cases, the e
argument represents an event parameter that can contain information about any request parameters. The structure of the event object is shown in the table below:
e.queryString
The value of the query string portion of the URL, or null
if no query string is specified
name=alice&n=1&n=2
e.parameter
An object of key/value pairs that correspond to the request parameters. Only the first value is returned for parameters that have multiple values.
{"name": "alice", "n": "1"}
e.parameters
An object similar to e.parameter
, but with an array of values for each key
{"name": ["alice"], "n": ["1", "2"]}
e.pathInfo
The URL path after /exec
or /dev
. For example, if the URL path ends in /exec/hello
, the path info is hello
.
e.contextPath
Not used, always the empty string. e.contentLength
The length of the request body for POST requests, or -1
for GET requests
332
e.postData.length
The same as e.contentLength
332
e.postData.type
The MIME type of the POST body
text/csv
e.postData.contents
The content text of the POST body
Alice,21
e.postData.name
Always the value "postData"
postData
For instance, you could pass parameters such as username
and age
to a URL as shown below:
https://script.google.com/.../exec?username=jsmith&age=21
Then, you can display the parameters like so:
function doGet(e) {
var params = JSON.stringify(e);
return ContentService.createTextOutput(params).setMimeType(ContentService.MimeType.JSON);
}
In the above example, doGet(e)
returns the following output:
{
"queryString": "username=jsmith&age=21",
"parameter": {
"username": "jsmith",
"age": "21"
},
"contextPath": "",
"parameters": {
"username": [
"jsmith"
],
"age": [
"21"
]
},
"contentLength": -1
}
Warning: The following parameter names are reserved by the system and shouldn't be used in URL parameters or POST bodies:
c
sid
To deploy a script as a web app, follow these steps:
You can share the web app URL with those you would like to use your app, provided you have granted them access.
Note: Web apps deployed in one domain cease to function if their ownership changes to a shared drive or account in a different domain. This can be corrected by having the new owner or collaborator redeploy the web app in the new domain. Alternatively, if the web app is moved back to its original domain the web app will start functioning again for that domain without redeploying. Test a web app deploymentTo test your script as a web app, follow the steps below:
Paste the URL in your browser and test your web app.
This URL ends in /dev
and can only be accessed by users who have edit access to the script. This instance of the app always runs the most recently saved code and is only intended for testing during development.
The permissions for a web app differ depending how you choose to execute the app:
In order to embed a web app in Google Sites, it must first be deployed. You also need the Deployed URL from the Deploy
dialog.
To embed a web app into a Sites page, follow these steps:
The web app appears in a frame in the page's preview. When you publish the page, your site viewers may need to authorize the web app before it executes normally. Unauthorized web apps present authorization prompts to the user.
Web Apps and Browser HistoryIt can be desirable to have an Apps Script web app simulate a multi-page application, or one with a dynamic UI controlled via URL parameters. In order to do this well, you can define a state object to represent the app's UI or page, and push the state into the browser history as the user navigates your app. You can also listen to history events so that your web app displays the correct UI when the user navigates back and forth with the browser buttons. By querying the URL parameters at load time, you can have your app dynamically build its UI based on those parameters, allowing the user to start the app in a particular state.
Apps Script provides two asynchronous client-side JavaScript APIs to assist with creating web apps that are linked to the browser history:
google.script.history
provides methods to allow dynamic response to browser history changes. This includes: pushing states (simple Objects you can define) onto the browser history, replacing the top state in the history stack, and setting a listener callback function to respond to history changes.
google.script.url
provides the means to retrieve the current page's URL parameters and URL fragment, if they are present.
These history APIs are only available to web apps. They are not supported for sidebars, dialogs or add-ons. This functionality is also not recommended for use in web apps embedded in a Google Sites.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["Google Apps Script can be published as a web app, enabling users to interact with it directly in their browsers."],["To publish as a web app, the script must contain a `doGet(e)` or `doPost(e)` function returning an HTML or TextOutput object."],["Web apps can be shared and embedded in Google Sites, subject to access permissions."],["Apps Script offers client-side JavaScript APIs (`google.script.history` and `google.script.url`) for managing browser history and URL parameters within web apps."],["When deploying as a web app, scripts can run as the owner or the user accessing it, with security considerations for each option."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4