Public
Like
parentProjectTemplate
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v7View latest version
This template demonstrates how to create a parent project that routes to multiple subprojects using Val Town projects.
- Parent Project Template: https://www.val.town/x/dcm31/parentProjectTemplate/code/
- Subproject Template: https://www.val.town/x/dcm31/subprojectTemplate/code/
This project uses a proxy-based routing architecture:
- The main HTTP handler serves the home page and handles navigation
- Requests to specific paths (e.g.,
/subproject
) are proxied to their respective subprojects - Each subproject is a separate Val Town project with its own environment and configuration
To set up your own parent-subproject architecture:
- Clone/fork this template for the parent project
- Clone/fork the subproject template for each subproject
- Update the
proxyRoutes
array inproxies.tsx
with your subproject endpoints - Customize the UI and content to fit your needs
To add a new subproject:
- Create a new Val Town project using the subproject template
- Add the project's endpoint URL to the
proxyRoutes
array inproxies.tsx
of this parent project - Add a navigation link in the parent project's homepage
To use this architecture with a custom domain:
- Set up your custom domain to point to the parent project's endpoint
- The routing will work automatically - subprojects will appear under their paths on your domain
- No additional configuration needed in the DNS settings
http.tsx
: The main HTTP handler that serves the home page and handles routingproxies.tsx
: Defines the routes to subprojects and the proxy logicREADME.md
: This file
- Clean separation between projects
- Each subproject has its own isolated environment variables
- Easy to add or modify subprojects without changing the parent project
- Unified user experience under a single domain