What are the Private and Functions folders?
The Private and Functions folders in the TeleportHQ Assets Manager are for developer files, not for images on your pages. The Private folder holds text files, such as a next.config.js, that are added to the top folder of your generated project when you publish or export. You show it with the Private Folder switch in Project settings → Editor → Preferences → Advanced features. The Functions folder holds .js files that run as server functions once your project is published.
The Private folder
The TeleportHQ Private folder is a place for configuration files and build scripts that your generated project needs. In the app's words, it "Contains sensitive information, such as configuration files or build scripts, which are essential for the project's development." Despite that wording, the Private folder doesn't hide or protect its files.
- It accepts text files only:
txt,xml,json,js,css,env,ymlandyaml. - It can't contain folders.
- When you publish or download your code, its files are added to the top folder of the generated project, next to files such as
package.json. Files in Public go to the site's public files instead.
Show the Private folder
- In the TeleportHQ editor, at the bottom of the left sidebar, click the Project settings cog.
- In the Project settings panel, under Editor, click Preferences.
- In the drawer, click Advanced features.
- Click the switch next to Private Folder. It turns on and saves at once; there's no Save button.
The Private folder now appears above Functions in the Assets Manager's Uploads tab. See How to turn on Advanced Features.
Add a file to the Private folder
- In the left sidebar, click Assets Manager, then Uploads.
- On the Private folder's row, click + (tooltip Upload asset).
- Pick your file, for example
next.config.js. - A Private files window warns: "Be careful, uploading incompatible or broken private files can potentially break the publication." Click Close. To stop seeing the warning, tick Don't show this again first.
To change a Private file later, right-click it and choose Edit. See How to edit uploaded text files.
The Functions folder
The TeleportHQ Functions folder holds JavaScript files that run on the server after your project is deployed. The app describes it as handling "Next.js cloud functions that run post-deployment, enabling dynamic server-side processes for your application." This is a feature for developers.
- It takes
.jsfiles, and it can't contain folders. It's always shown in the Uploads tab, above Public. - To add a function, click + on the Functions folder's row (tooltip Upload asset) and pick your file, for example
send-order.js. - When you publish, or download your project as Next.js code, each file becomes an API route:
send-order.jsanswers at/api/send-order. Other code formats, such as HTML, leave the Functions folder out. - If a function imports an npm package, TeleportHQ adds that package to the project's dependencies.
- After you publish to a TeleportHQ address, right-click a function file and choose Copy Function Link to Clipboard to copy its address. The option is greyed out until the project has been published to a TeleportHQ address.
Troubleshooting
"You can only upload text type files to the private folder (.txt, .xml, .yaml, .js, .json, .css, ...)" You uploaded another type of file, such as an image. It was removed from the Private folder. Upload images to Public instead.
"Error occurred while publishing" with "We noticed that you have added private files, which could be causing the error." A file in the Private folder may be breaking the build. Click Publish without private files to publish without them, then check and fix the file. See Publishing failed: what should I do?
Copy Function Link to Clipboard is greyed out The project hasn't been published to a TeleportHQ address yet. Publish it, then try again. See How to publish your site.
Good to know
- The Public folder holds everything you use on your pages or offer for download.
- Turning Private Folder off only hides the folder in the Assets Manager. The files in it are still added when you publish or download your code. To leave them out, delete them. See How to rename or delete files (and remove unused ones).
- Point at the Private, Functions or Public folder name and its info icon to read what the folder is for.