Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getStaticPaths() function required for dynamic routes from _server-islands.astro #12636

Open
1 task
T1xx1 opened this issue Dec 4, 2024 · 9 comments
Open
1 task
Assignees
Labels
feat: server islands Related to Server Islands (scope) needs triage Issue needs to be triaged

Comments

@T1xx1
Copy link

T1xx1 commented Dec 4, 2024

Astro Info

Astro                    v5.0.2
Node                     v23.1.0
System                   Windows (x64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/vercel
Integrations             @astrojs/svelte
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I think when index.astro loads all its content is wrapped in theme.astro which is a server island bugs the link to pageb/[id].astro generated with getStaticPaths

What's the expected result?

Build my static paths inside the server island.

The docs don't specify I can't put links to static pages inside server islands

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-m5m9za?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 4, 2024
@T1xx1 T1xx1 changed the title getStaticPaths() function required for dynamic routes from _server-islands.astro getStaticPaths() function required for dynamic routes from _server-islands.astro Dec 4, 2024
@ematipico ematipico added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: server islands Related to Server Islands (scope) labels Dec 5, 2024
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Dec 5, 2024
@ematipico ematipico self-assigned this Dec 5, 2024
@sannajammeh
Copy link

sannajammeh commented Dec 15, 2024

Its not only for dynamic routes either.

I have an astro project with a single index.astro component and use a server:defer directive on a component, this now throws the same error.

export const prerender = false from the index route doesn't work either.

The only solution seems to be enabling output: server in the Astro config. This seems like a bug as the error is thrown directly in the _server-islands.astro component

@ematipico ematipico removed the - P4: important Violate documented behavior or significantly impacts performance (priority) label Dec 17, 2024
@ematipico
Copy link
Member

Closing. Server islands, as the name says, are a server feature. It requires an adapter to function. In the reproduction, output: "server" wasn't present, and it must be provided.

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@jee-r
Copy link

jee-r commented Dec 17, 2024

In Astro 5.0, we’re happy to say that we’ve simplified all of this: the hybrid and static options have been merged into the default static option. This now allows you to render individual routes at runtime on the server just by adding an adapter, no other configuration is required.

Fear not, if you still want good old statically generated .html files, you’ll still get them: Astro is still static by default! But, if you happen to set one of your pages to prerender = false, Astro will now dynamically switch its output mode, allowing you to use features that require server-side rendering without figuring out which configuration mode you need.

https://astro.build/blog/astro-5/#simplified-prerendering

@ematipico
Copy link
Member

@jee-r

The reproduction doesn't even have an adapter. Without an adapter, the build output can't be changed to server automatically.

@T1xx1
Copy link
Author

T1xx1 commented Dec 17, 2024

I don't want my site to be build on the server every time. In Astro 4 I had the output to hybrid mode so I could prerender my pages but still have server islands in them and everything worked fine.

In Astro 5.0, we’re happy to say that we’ve simplified all of this: the hybrid and static options have been merged into the default static option. This now allows you to render individual routes at runtime on the server just by adding an adapter, no other configuration is required.
Fear not, if you still want good old statically generated .html files, you’ll still get them: Astro is still static by default! But, if you happen to set one of your pages to prerender = false, Astro will now dynamically switch its output mode, allowing you to use features that require server-side rendering without figuring out which configuration mode you need.

None of this nor the documentation states that I can or cannot use server islands in pre-rendered routes in the new "static-hybrid" mode.

Now in Astro 5 how I'm supposed to have dynamic content like a island that shows the time the page has been requested in a blog?

Am I missing something? Because if not now I'm forced to render my routes on the server or give up dynamic content

@ematipico
Copy link
Member

ematipico commented Dec 17, 2024

@T1xx1

Server islands need an adapter, because they are on-demand resources: https://docs.astro.build/en/guides/server-islands/

You can still build your pages statically, however when you use a server island, you'll need an adapter (node, vercel, etc.) that will serve that island for your static page.

I hope that clears things out.

@T1xx1
Copy link
Author

T1xx1 commented Dec 17, 2024

Kinda...

By the way, adding the adapter still doesn't shuts up the error when I'm working on localhost

@ematipico ematipico reopened this Dec 17, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 17, 2024
@T1xx1
Copy link
Author

T1xx1 commented Dec 18, 2024

I added the adapter in the reproduction using astro add and it's still not working something is clearly off with dynamic content in static routes

@jee-r
Copy link

jee-r commented Dec 18, 2024

Thank you for clarification @ematipico
i think this is related to #12744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: server islands Related to Server Islands (scope) needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants