Public
Like
subprojectTemplate
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: v4View latest version
This template demonstrates how to create a subproject that works with the parent project routing architecture.
- Parent Project Template: https://www.val.town/x/dcm31/parentProjectTemplate/code/
- Subproject Template: https://www.val.town/x/dcm31/subprojectTemplate/code/
This subproject is designed to be accessed through a parent project via path-based routing. It includes:
- Automatic path handling for both direct and proxied requests
- Navigation between subproject pages
- Navigation back to the parent project
- Simple page routing system
- Clone/fork this template for each subproject you want to create
- Update the
config
object inhttp.tsx
to match your project's name and path - Add your subproject's endpoint to the parent project's
proxies.tsx
file - Customize the pages and content to fit your needs
To connect this subproject with a parent project:
- Get your subproject's endpoint URL (available after deployment)
- Add an entry to the
proxyRoutes
array in the parent project'sproxies.tsx
:
{
pattern: '/your-subproject-path',
target: 'https://your-username--endpoint-id.web.val.run',
name: 'Your Subproject Name'
}
This template automatically handles paths whether accessed directly or through the parent project:
- If accessed via parent:
parentdomain.com/subproject/about
- If accessed directly:
subproject-endpoint.web.val.run/about
Both scenarios are properly handled by the path processing logic in the request handler.
- Update the
config
object to change the project name and base path - Modify the pages in the App component (HomePage, AboutPage, etc.)
- Customize the styles in the style tag
- Add new routes and components as needed
- Clean separation of concerns
- Independent development and deployment
- Shared navigation and user experience
- No need for complex domain configuration